Search code examples
androidandroid-activityandroid-dialogfragmentandroid-dialogandroid-windowmanager

Window manager animator state and activity back stack


I wonder if those two are related.

I have a problem with displaying dialog on top of another activity. What I think I do is:

  • start activity to make a phone call,
  • BroadcastReceiver which listens for Intent.ACTION_NEW_OUTGOING_CALL starts activity (with Intent.FLAG_ACTIVITY_NEW_TASK flag) which will display the dialog (let's call it InCallActivity),
  • in onCreate of InCallActivity I build a DialogFragment and then display it.

What I see is just com.android.dialer/com.android.incallui.InCallActivity with no dialog of mine.

dumpsys window animator says

  Window #0: WindowStateAnimator{42433660 com.android.systemui.ImageWallpaper}
  Window #1: WindowStateAnimator{428f9a20 com.google.android.googlequicksearchbox/com.google.android.launcher.GEL}
  Window #2: WindowStateAnimator{4287ae60 com.android.settings/com.android.settings.DevelopmentSettings}
  Window #3: WindowStateAnimator{42800678 com.android.settings/com.sprd.settings.SprdUsbSettings}
  Window #4: WindowStateAnimator{428939d8 myApp/myApp.MainActivity}
  Window #5: WindowStateAnimator{42835be0 myApp/myApp.InCallActivity} <- that's probably the activity itself
  Window #6: WindowStateAnimator{4283f518 myApp/myApp.InCallActivity} <- that's probably the dialog
  Window #7: WindowStateAnimator{4282de98 com.android.dialer/com.android.incallui.InCallActivity}
  Window #8: WindowStateAnimator{426e5cb0 InputMethod}
  Window #9: WindowStateAnimator{424e09b8 KeyguardScrim}
  Window #10: WindowStateAnimator{424dd0a8 Keyguard}
  Window #11: WindowStateAnimator{422c4598 StatusBar}

and android.task.incallui is always on top of task stack

Running activities (most recent first):
  TaskRecord{427a9cf8 #745 A=android.task.incallui U=0 sz=1}
    Run #4: ActivityRecord{423c18e8 u0 com.android.dialer/com.android.incallui.InCallActivity t745}
  TaskRecord{427d0768 #744 A=myApp U=0 sz=1}
    Run #3: ActivityRecord{42373f28 u0 myApp/.InCallActivity t744}
  TaskRecord{424b8170 #743 A=myApp U=0 sz=2}
    Run #2: ActivityRecord{422f0fb0 u0 myApp/.MainActivity t743}
  TaskRecord{4289c550 #657 A=com.sprd.settings.SprdUsbSettings U=0 sz=1}
    Run #1: ActivityRecord{41ac4b30 u0 com.android.settings/com.sprd.settings.SprdUsbSettings t657}
  TaskRecord{42778c78 #522 A=com.android.settings U=0 sz=1}
    Run #0: ActivityRecord{41a8a0b0 u0 com.android.settings/.DevelopmentSettings t522}

mResumedActivity: ActivityRecord{423c18e8 u0 com.android.dialer/com.android.incallui.InCallActivity t745}
mLastPausedActivity: ActivityRecord{42373f28 u0 myApp/.InCallActivity t744}

How to show that dialog on top of com.android.dialer/com.android.incallui.InCallActivity?


Solution

  • Well, I found a workaround. Instead of displaying activity as a dialog (or dialog in an activity), I just run a service which displays widget (adds new view) with LayoutParams, such as TYPE_SYSTEM_ALERT.