标签:推荐 code 导致 oid 包名 使用 推送 pac proc
我之前一直採用的是System.exit(0);
今天看到有人说这种方法不太好。这是J2SE里的方法,他主要是通过终止正在执行的JAVA虚拟机。导致程序终止。
推荐下面方法:
1.杀死本进程:
android.os.Process.killProcess(android.os.Process.myPid());
ActivityManager manager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE); manager.killBackgroundProcesses("包名");
<uses-permission android:name="android.permission.RESTART_PACKAGES"/>
我原来使用的System.exit(0);是能够的。
2014.7.2更:
今天又看到有人说System.exit(0);是比較好的方法,他使程序正常退出。
而android.os.Process.killProcess(android.os.Process.myPid());则是强制垃圾回收。我类个去。
标签:推荐 code 导致 oid 包名 使用 推送 pac proc
原文地址:http://www.cnblogs.com/ljbguanli/p/6756725.html