强制应用程序重新启动的第一项活动 [英] Force application to restart on first activity

查看:105
本文介绍了强制应用程序重新启动的第一项活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于未知的原因,我不能让我的应用程序留下正确的,这样,当我再次按下home键和应用程序的图标,我继续在那里我是在应用程序。 我想强制应用程序重新启动的第一项活动。

For an unknown reason, I can't get my application leaving properly so that when I push the home button and the app icon again, I resume where I was in the app. I would like to force the application to restart on the first Activity.

我想这已经是与的onDestroy()或者在onPause(),但我不知道该怎么办。

I suppose this has something to do with onDestroy() or maybe onPause() but I don't know what to do.

推荐答案

下面是一个例子使用PackageManager重新启动的一种通用方式您的应用程序:

Here is an example to restart your app in a generic way by using the PackageManager:

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

这篇关于强制应用程序重新启动的第一项活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆