我曾经FLAG_ACTIVITY_REORDER_TO_FRONT
尝试在活动之间切换。由于这是越野车(有时回来时隐藏),所以我尝试潜入它。
正如我从 adb 中看到的FLAG_ACTIVITY_REORDER_TO_FRONT
那样,并没有真正使活动移到顶部,活动顺序从未改变:
xb@dnxb:~/Downloads$ adb shell dumpsys window windows | grep -n 'Window #'
2: Window #13 Window{f7d02ea u0 NavigationBar}:
31: Window #12 Window{fdfb1ed u0 com.android.systemui}:
56: Window #11 Window{b626be1 u0 StatusBar}:
84: Window #10 Window{bd80846 u0 KeyguardScrim}:
109: Window #9 Window{f127fe9 u0 AssistPreviewPanel}:
134: Window #8 Window{f5a5c17 u0 DockedStackDivider}:
162: Window #7 Window{5170bb1 u0 com.android.systemui}:
188: Window #6 Window{201fb75 u0 InputMethod}:
217: Window #5 Window{7555f63 u0 com.stackoverflow/mythirdActivity}:
246: Window #4 Window{7e3a230 u0 com.stackoverflow/mySecondActivity}:
273: Window #3 Window{7a4b856 u0 com.stackoverflow/myFirstActivity}:
300: Window #2 Window{cc1c79f u0 com.huawei.android.launcher/com.huawei.android.launcher.unihome.UniHomeLauncher}:
329: Window #1 Window{f2df7b0 u0 com.android.systemui/com.android.systemui.recents.RecentsActivity}:
357: Window #0 Window{5a3ffdc u0 com.anifree.engine.Wallpaper}:
FLAG_ACTIVITY_REORDER_TO_FRONT
仅从此更改“焦点状态”:
mDrawState=NO_SURFACE mLastHidden=true
对此:
mSurface=Surface(name=com.stackoverflow/mySecondActivity)
Surface: shown=true layer=21020 alpha=1.0 rect=(0.0,0.0) 1080.0 x 1920.0 blurRadius = 0 blurRound = (0,0) blurAlpha = 0.0 blurRegion = null blurBlank = null
mDrawState=HAS_DRAWN mLastHidden=false
但是,如果我按主页按钮播放,我可以看到启动器窗口能够“真正移动”到顶部:
xb@dnxb:~/Downloads$ adb shell dumpsys window windows | grep -n 'Window #'
2: Window #13 Window{f7d02ea u0 NavigationBar}:
31: Window #12 Window{fdfb1ed u0 com.android.systemui}:
56: Window #11 Window{b626be1 u0 StatusBar}:
84: Window #10 Window{bd80846 u0 KeyguardScrim}:
109: Window #9 Window{f127fe9 u0 AssistPreviewPanel}:
134: Window #8 Window{f5a5c17 u0 DockedStackDivider}:
162: Window #7 Window{5170bb1 u0 com.android.systemui}:
188: Window #6 Window{201fb75 u0 InputMethod}:
217: Window #5 Window{cc1c79f u0 com.huawei.android.launcher/com.huawei.android.launcher.unihome.UniHomeLauncher}:
248: Window #4 Window{f2df7b0 u0 com.android.systemui/com.android.systemui.recents.RecentsActivity}:
217: Window #5 Window{7555f63 u0 com.stackoverflow/mythirdActivity}:
246: Window #4 Window{7e3a230 u0 com.stackoverflow/mySecondActivity}:
273: Window #3 Window{7a4b856 u0 com.stackoverflow/myFirstActivity}:
357: Window #0 Window{5a3ffdc u0 com.anifree.engine.Wallpaper}:
xb@dnxb:~/Downloads$
由于隐藏/取消隐藏到背景以移动窗口是可能的,这让我想知道是否有可能以编程方式使 mySecondActivity 位于 mythirdActivity 之上,如下所示:
Window #4 Window{7e3a230 u0 com.stackoverflow/mySecondActivity}:
Window #5 Window{7555f63 u0 com.stackoverflow/mythirdActivity}:
Window #3 Window{7a4b856 u0 com.stackoverflow/myFirstActivity}:
请注意,我不是在谈论新实例,我的意思是相同的窗口 IDWindow{7e3a230
移动到顶部而不更改窗口 ID。
可能吗 ?还是我误解了?