当我开发一个Android应用程序时,如何退出这个应用程序?我尝试了我能做的任何事情,但我无法退出我正在开发的应用程序。这个怎么做 ?任何想法?
这是我的解决方案,如下所示,
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;
}
// When an activity is created ,excute this method ,addActivity(activity)
public void addActivity(Activity activity) {
mList.add(activity);
}
//When I want to exit this aplication ,excute this method ,exit()
public void exit() {
for (Activity activity : mList) {
activity.finish();
}
System.exit(0);
}
@Override
public void onLowMemory() {
super.onLowMemory();
System.gc();
}
}