Android中完全退出APP的方法
来源:互联网 发布:iphone手机必备软件 编辑:程序博客网 时间:2024/04/29 16:42
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>
- Android中完全退出APP的方法
- android中完全退出应用程序的方法
- android 完全退出App
- Android完全退出App的一些问题
- Android开发,完全退出APP的实现
- Android开发中完全退出程序的三种方法
- Android中完全退出程序的四种方法
- android中完全退出当前应用程序的四种方法
- android中完全退出当前程序的几种方法
- Android开发中完全退出程序的三种方法
- Android开发中完全退出程序的三种方法
- android中完全退出当前应用程序的四种方法
- Android开发中完全退出程序的三种方法
- android中完全退出当前应用程序的四种方法
- Android开发中完全退出程序的三种方法
- Android开发中完全退出程序的三种方法
- android中完全退出当前应用程序的四种方法
- Android开发中完全退出程序的三种方法
- Java String.format 方法使用介绍
- Mysql函数总结(3)——日期时间函数
- CTO俱乐部下午茶:技术团队管理中的那些事儿
- CareerCup 4.3
- Go语言实战 - 创业进行时之用户注册
- Android中完全退出APP的方法
- hdu1226 BFS
- MFC程序的与window程序的区别及需要的库和头文件
- 不需Developper认证的真机调试(需要越狱)
- Siebel Update 8.1.1.9的相关补丁
- 小爬虫——下载给定网页上的图片
- 【原创】开源中国阅读小记 - 1
- 【原创】开源中国阅读小记 - 2 - 单例
- Mac OS X快捷键指南 + xcode常用快捷键