当前位置:首页 > android 退出应用程序的方法

android 退出应用程序的方法

点击次数:1646  更新日期:2013-07-01

如果是在主页面上,用下面这个方法就可以退出程序了。

android.os.Process.killProcess(android.os.Process.myPid());

如果不是主页面,那么则可以将主页面设为单例模式,然后再其他页面上用Intent来实现

public void onNewIntent(Intent it) {

   super.onNewIntent(it);

   if (it.hasExtra("exit")) {//如果传过来的参数中含有exit,就退出

       android.os.Process.killProcess(android.os.Process.myPid());

   }

}