android 在系統crash時往往UI線程會出現問題,這個時間關於界面的圖像顯示往往會出現問題,
總結了兩種顯示 方法,顯示Toast,或者跳轉Activity
顯示Toast
Looper.prepare();
Toast.makeText(mContext, Message.CLOSE_FOR_UNEXPECTED_REASON, Toast.LENGTH_LONG).show();
Looper.loop();
關於Activity的跳轉
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startMain.setAction("com.test.LOGIN");
startMain.addCategory("com.test.LOGIN");
startMain.setComponent(new ComponentName("com.test", "com.test.MainActivity"));
mContext.startActivity(startMain);
要在AndroidManifest,xml中Activity加入category
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@android:style/Theme.Light.NoTitleBar"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="com.test.LOGIN" />
<category android:name="com.test.LOGIN" />
</intent-filter>
</activity>