在一些设备上,某种条件下调用Unity?C#的Application.quit()接口会导致闪退。需要改为调用Android原生接口,代码如下:
activity.finish();
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
报错如下:
10403-28 18:27:05.162 25084 25084 W Unity : Timeout while trying to pause the Unity Engine.
10503-28 18:27:05.191 25084 25084 E ANR_LOG : >>> msg's executing time is too long
10603-28 18:27:05.192 25084 25084 E ANR_LOG : Blocked msg = { when=-4s32ms what=102 target=android.app.ActivityThread$H obj=android.os.BinderProxy@3bfac69e } , cost = 4032 ms
10703-28 18:27:05.192 25084 25084 E ANR_LOG : >>>Current msg List is:
10803-28 18:27:05.192 25084 25084 E ANR_LOG : Current msg <1> = { when=-4s32ms what=0 target=android.os.Handler callback=$Proxy3 }
10903-28 18:27:05.192 25084 25084 E ANR_LOG : Current msg <2> = { when=-4s30ms what=0 target=android.os.Handler callback=com.unity3d.player.UnityPlayer$8 }
11003-28 18:27:05.192 25084 25084 E ANR_LOG : Current msg <3> = { when=-4s26ms what=0 target=android.app.ActivityThread$H callback=android.app.LoadedApk$ServiceDispatcher$RunConnection }
11103-28 18:27:05.192 25084 25084 E ANR_LOG : Current msg <4> = { when=-3s994ms what=0 target=android.app.ActivityThread$H callback=android.app.LoadedApk$ServiceDispatcher$RunConnection }
11203-28 18:27:05.193 25084 25084 E ANR_LOG : Current msg <5> = { when=-3s896ms what=17 target=android.view.ViewRootImpl$ViewRootHandler obj=android.view.ViewRootImpl$SystemUiVisibilityInfo@359d6abc }
11303-28 18:27:05.193 25084 25084 E ANR_LOG : Current msg <6> = { when=-3s894ms what=118 target=android.app.ActivityThread$H obj={1.12 ?mcc?mnc zh_CN ?layoutDir sw360dp w360dp h622dp 480dpi nrml long port finger -keyb/v/h -nav/h s.44mThemeChanged = 0mThemeChangedFlags = 0mFlipFont = 0} }
11403-28 18:27:05.193 25084 25084 E ANR_LOG : Current msg <7> = { when=-3s881ms what=2 target=android.hardware.display.DisplayManagerGlobal$DisplayListenerDelegate }
11503-28 18:27:05.193 25084 25084 E ANR_LOG : Current msg <8> = { when=-3s881ms what=2 target=android.hardware.display.DisplayManagerGlobal$DisplayListenerDelegate }
11603-28 18:27:05.194 25084 25084 E ANR_LOG : Current msg <9> = { when=-3s864ms what=8 target=android.view.ViewRootImpl$ViewRootHandler }
11703-28 18:27:05.194 25084 25084 E ANR_LOG : Current msg <10> = { when=-3s864ms what=130 target=com.android.internal.view.IInputConnectionWrapper$MyHandler arg1=247 }
11803-28 18:27:05.194 25084 25084 E ANR_LOG : Current msg <11> = { when=-3s862ms what=3 target=android.view.SurfaceView$1 }
11903-28 18:27:05.194 25084 25084 E ANR_LOG : Current msg <12> = { when=-3s862ms what=5 target=android.view.ViewRootImpl$ViewRootHandler obj=com.android.internal.os.SomeArgs@13f3ea45 }
12003-28 18:27:05.204 25084 25084 E ANR_LOG : Current msg <13> = { when=-3s855ms what=4 target=android.view.inputmethod.InputMethodManager$H }
12103-28 18:27:05.204 25084 25084 E ANR_LOG : Current msg <14> = { when=-3s855ms what=3 target=android.view.inputmethod.InputMethodManager$H arg1=331 }
12203-28 18:27:05.205 25084 25084 E ANR_LOG : Current msg <15> = { when=-3s807ms what=100 target=com.android.internal.view.IInputConnectionWrapper$MyHandler }
12303-28 18:27:05.205 25084 25084 E ANR_LOG : Current msg <16> = { when=-3s807ms what=65 target=com.android.internal.view.IInputConnectionWrapper$MyHandler }
12403-28 18:27:05.205 25084 25084 E ANR_LOG : Current msg <17> = { when=-3s761ms what=17 target=android.view.ViewRootImpl$ViewRootHandler obj=android.view.ViewRootImpl$SystemUiVisibilityInfo@699f59a }
12503-28 18:27:05.205 25084 25084 E ANR_LOG : Current msg <18> = { when=-3s731ms what=0 target=android.app.ActivityThread$H callback=android.app.LoadedApk$ServiceDispatcher$RunConnection }
12603-28 18:27:05.205 25084 25084 E ANR_LOG : Current msg <19> = { when=-3s462ms what=140 target=android.app.ActivityThread$H arg1=20 }
12703-28 18:27:05.205 25084 25084 E ANR_LOG : Current msg <20> = { when=-3s462ms what=109 target=android.app.ActivityThread$H arg1=1 obj=android.os.BinderProxy@3bfac69e }
12803-28 18:27:05.205 25084 25084 E ANR_LOG : >>>CURRENT MSG DUMP OVER<<<
|