android关于crash时的提示信息,与页面跳转

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>




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章