Android 怎么退出整个应用程序?
来源:互联网 发布:java软件编程培训费用 编辑:程序博客网 时间:2024/05/22 09:39
在开发andorid程序的时候,难免会牵扯到退出整个应用程序的情况,怎么完全退出呢?请参阅下面的关键代码:
- import java.util.LinkedList;
- import java.util.List;
- import android.app.Activity;
- import android.app.AlertDialog;
- import android.app.Application;
- import android.content.DialogInterface;
- import android.content.Intent;
- public class SysApplication extends Application {
- private List<Activity> mList = new LinkedList<Activity>();
- private static SysApplication instance;
- private SysApplication() {
- }
- public synchronized static SysApplication getInstance() {
- if (null == instance) {
- instance = new SysApplication();
- }
- return instance;
- }
- // add Activity
- public void addActivity(Activity activity) {
- mList.add(activity);
- }
- public void exit() {
- try {
- for (Activity activity : mList) {
- if (activity != null)
- activity.finish();
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- System.exit(0);
- }
- }
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- System.gc();
- }
- }
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- SysApplication.getInstance().addActivity(this);
- }
0 0
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序? .
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序?
- Android 怎么退出整个应用程序?
- create a cocos2d-x-3.0 project in Xcode
- 让powershell在不显示提示信息的情况下通过Internet上下载的ps脚本
- x264 - x264_me_search_ref
- ACM抽象基类
- Androidの共享登录之方案研究
- Android 怎么退出整个应用程序?
- 数据结构CCDictionary
- 幸运大转盘-jQuery+PHP实现的抽奖程序
- JS操作JSON读书笔记
- DSP/BIOS 常用API总结
- C++ 堆和栈的比较
- 解决getOutputStream() has already been called for this response
- Tokyo Cabinet vs Redis
- destoon URL Rewrite(伪静态)设置方法