2013-09-26 49 views
1

我想从内部活动重新开始我的应用程序,我看到here,我要这样的代码:强制应用程序重新启动的Android

Intent i = getBaseContext().getPackageManager() 
      .getLaunchIntentForPackage(getBaseContext().getPackageName()); 
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
startActivity(i); 

问题是,当我使用FLAG_ACTIVITY_CLEAR_TOP标志的应用程序退出,并没有重新启动。 有什么建议吗?

+0

请按照下面的链接http://stackoverflow.com/questions/6609414/howto-programatically-restart-android-app – Amit

回答

2

在我的情况下,调用System.exit(0)关闭当前活动,解决问题。

Intent i = getBaseContext().getPackageManager() 
      .getLaunchIntentForPackage(getBaseContext().getPackageName()); 
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
startActivity(i); 
System.exit(0); 
相关问题