1.在,要执行退出的activity中进行相关配置
public static final String ALL_EXIT = "COM.DEVDIV.TEST.EXIT";// 申明通知
【使用】
public static void fullExit(Context context) {
Intent intent = new Intent(context, WelcomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setAction(APP.ALL_EXIT);
context.startActivity(intent);
}
2.在初始页面重写方法
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent.getAction().endsWith(APP.ALL_EXIT)) {
finish();
System.exit(0);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
finish();
System.exit(0);
}
3.在配置文件中初始Activity中添加配置【android:launchMode="standard"】
<activity
android:name=".WelcomeActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
public static final String ALL_EXIT = "COM.DEVDIV.TEST.EXIT";// 申明通知
【使用】
public static void fullExit(Context context) {
Intent intent = new Intent(context, WelcomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setAction(APP.ALL_EXIT);
context.startActivity(intent);
}
2.在初始页面重写方法
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent.getAction().endsWith(APP.ALL_EXIT)) {
finish();
System.exit(0);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
finish();
System.exit(0);
}
3.在配置文件中初始Activity中添加配置【android:launchMode="standard"】
<activity
android:name=".WelcomeActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>