当点击应用程序图标,打开Android应用程序重新启动应用程序、重新启动、图标、Android

2023-09-12 05:10:38 作者:独跳华尔兹。

方案:

我打开我的应用程序通过点击图标,有所为有所不为,浏览活动,通过点击主页按钮暂停应用程序。

I open my app by clicking icon, do something, navigate through activities, pause the app by clicking home button.

案例1:的

如果我再次点击图标打开我的应用程序,该应用程序重新启动的第一项活动。

If I open my app by clicking icon again, the app restarts from the first activity.

案例2:的

如果我从最近打开的应用程序打开我的应用程序(在4.0由pressing菜单按钮,然后选择我的应用程序),它开始从暂停状态。

If I open my app from recently open apps (in 4.0 by pressing menu button and selecting my app) it starts from the paused state.

我想要的行为2总是发生,不希望我的应用程序,以重新启动每次当它通过点击图标可打开的时间。

I want the behavior 2 always to occur, don't want my app to restart every time when it is opened by clicking icon.

我比较了我的清单文件与其他应用程序,他们与我相似,但不同的行为(例如像,我想第二种情况)。

I have compared my manifest file with other apps and they are similar to mine, but behave differently (i.e like 2nd case which i want).

编辑:

这已经在这里问:App通过图标preSS在启动

但没有答案:(

推荐答案

我发现了它。我已经设置一个标志机器人:在我的活动标志launchMode =singleTask 的。我删除了code。

I found it. I had set a flag android:launchMode="singleTask" in my activity flag. I deleted that code.

我还添加了 onsaveInstance 方法,在我的code的所有活动,它现在的工作!

I also added onsaveInstance method to all the activities in my code and it's working now!

感谢:)