C# 当应用程序使用后退按钮进入睡眠状态时,Xamarin问题

C# 当应用程序使用后退按钮进入睡眠状态时,Xamarin问题,c#,android,xamarin,C#,Android,Xamarin,我对mi xamarin应用程序有一个问题,如果我的应用程序使用手机的home(主页)按钮进入睡眠,它的简历没有问题,但是如果我使用back(后退)按钮,应用程序在白色屏幕上保持冻结,并且从不点击OnResume(),我希望它具有相同的行为,或者至少使用back(后退)按钮完全关闭应用程序 代码 使用“主页”按钮时的输出 12-23 11:23:35.517 D/ViewRootImpl@b3d0e31[MainActivity](15966): Relayout returned: old=(

我对mi xamarin应用程序有一个问题,如果我的应用程序使用手机的home(主页)按钮进入睡眠,它的简历没有问题,但是如果我使用back(后退)按钮,应用程序在白色屏幕上保持冻结,并且从不点击OnResume(),我希望它具有相同的行为,或者至少使用back(后退)按钮完全关闭应用程序

代码

使用“主页”按钮时的输出

12-23 11:23:35.517 D/ViewRootImpl@b3d0e31[MainActivity](15966): Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)4 dur=21 res=0x1 s={false 0} ch=false
12-23 11:23:35.518 D/ViewRootImpl@b3d0e31[MainActivity](15966): stopped(false) old=true
12-23 11:23:35.620 D/ViewRootImpl@b3d0e31[MainActivity](15966): stopped(false) old=false
12-23 11:23:35.705 D/ViewRootImpl@b3d0e31[MainActivity](15966): Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)0 dur=28 res=0x7 s={true 530976370688} ch=true
12-23 11:23:35.705 D/OpenGLRenderer(15966): createReliableSurface : 0x7bf7e1bf80, 0x7ba0a87000
12-23 11:23:35.739 D/mali_winsys(15966): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
12-23 11:23:35.950 I/om.kuwaidev.tp(15966): Explicit concurrent copying GC freed 2262(149KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 3171KB/6343KB, paused 77us total 27.240ms
12-23 11:23:35.954 D/Mono    (15966): GC_TAR_BRIDGE bridges 537 objects 25741 opaque 12967 colors 537 colors-bridged 537 colors-visible 537 xref 7 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.10ms tarjan 19.63ms scc-setup 0.18ms gather-xref 0.01ms xref-setup 0.01ms cleanup 2.11ms
12-23 11:23:35.954 D/Mono    (15966): GC_BRIDGE: Complete, was running for 34.77ms
12-23 11:23:35.954 D/Mono    (15966): GC_MINOR: (Nursery full) time 35.83ms, stw 37.16ms promoted 675K major size: 8784K in use: 7971K los size: 7168K in use: 5791K
12-23 11:23:35.983 D/ViewRootImpl@b3d0e31[MainActivity](15966): MSG_WINDOW_FOCUS_CHANGED 1 1
12-23 11:23:35.984 D/InputMethodManager(15966): prepareNavigationBarInfo() DecorView@fbe4d10[MainActivity]
12-23 11:23:35.984 D/InputMethodManager(15966): getNavigationBarColor() -11427245
12-23 11:23:36.002 D/InputMethodManager(15966): prepareNavigationBarInfo() DecorView@fbe4d10[MainActivity]
12-23 11:23:36.002 D/InputMethodManager(15966): getNavigationBarColor() -11427245
12-23 11:23:36.003 V/InputMethodManager(15966): Starting input: tba=com.kuwaidev.tpv ic=null mNaviBarColor -11427245 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
12-23 11:23:36.003 D/InputMethodManager(15966): startInputInner - Id : 0
12-23 11:23:36.003 I/InputMethodManager(15966): startInputInner - mService.startInputOrWindowGainedFocus

使用“后退”按钮时的输出在应用程序生命周期事件中,“后退”和“主页”按钮的行为不同。 按home将显示应用程序的背景;因此,当再次启动应用程序时,它将通过OnResume。相反,按Back键会终止应用程序。因此,当再次启动时,它将通过OnStart


这是支持的按钮。

Android上的后退按钮退出应用程序。
12-23 11:23:35.517 D/ViewRootImpl@b3d0e31[MainActivity](15966): Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)4 dur=21 res=0x1 s={false 0} ch=false
12-23 11:23:35.518 D/ViewRootImpl@b3d0e31[MainActivity](15966): stopped(false) old=true
12-23 11:23:35.620 D/ViewRootImpl@b3d0e31[MainActivity](15966): stopped(false) old=false
12-23 11:23:35.705 D/ViewRootImpl@b3d0e31[MainActivity](15966): Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)0 dur=28 res=0x7 s={true 530976370688} ch=true
12-23 11:23:35.705 D/OpenGLRenderer(15966): createReliableSurface : 0x7bf7e1bf80, 0x7ba0a87000
12-23 11:23:35.739 D/mali_winsys(15966): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
12-23 11:23:35.950 I/om.kuwaidev.tp(15966): Explicit concurrent copying GC freed 2262(149KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 3171KB/6343KB, paused 77us total 27.240ms
12-23 11:23:35.954 D/Mono    (15966): GC_TAR_BRIDGE bridges 537 objects 25741 opaque 12967 colors 537 colors-bridged 537 colors-visible 537 xref 7 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.10ms tarjan 19.63ms scc-setup 0.18ms gather-xref 0.01ms xref-setup 0.01ms cleanup 2.11ms
12-23 11:23:35.954 D/Mono    (15966): GC_BRIDGE: Complete, was running for 34.77ms
12-23 11:23:35.954 D/Mono    (15966): GC_MINOR: (Nursery full) time 35.83ms, stw 37.16ms promoted 675K major size: 8784K in use: 7971K los size: 7168K in use: 5791K
12-23 11:23:35.983 D/ViewRootImpl@b3d0e31[MainActivity](15966): MSG_WINDOW_FOCUS_CHANGED 1 1
12-23 11:23:35.984 D/InputMethodManager(15966): prepareNavigationBarInfo() DecorView@fbe4d10[MainActivity]
12-23 11:23:35.984 D/InputMethodManager(15966): getNavigationBarColor() -11427245
12-23 11:23:36.002 D/InputMethodManager(15966): prepareNavigationBarInfo() DecorView@fbe4d10[MainActivity]
12-23 11:23:36.002 D/InputMethodManager(15966): getNavigationBarColor() -11427245
12-23 11:23:36.003 V/InputMethodManager(15966): Starting input: tba=com.kuwaidev.tpv ic=null mNaviBarColor -11427245 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
12-23 11:23:36.003 D/InputMethodManager(15966): startInputInner - Id : 0
12-23 11:23:36.003 I/InputMethodManager(15966): startInputInner - mService.startInputOrWindowGainedFocus