2

How can I detect if a device has 'do not keep activities' set in developer options. I can't find this value in the settings-class.

I need this setting to know, because when 'do not keep activities' is activated my app gets problem with it. Example : I have a main-activity and a sub-activity. when I switch from main to sub and back from sub to main, then the main-activity will be started again. This is because the mainactivity was killed before. besause I do a lot of loading in my main-activity, the app is not usable when starting over and over.

Or is there any method to solve this problem ? Without this setting activated, there is no problem.

regards

4

2 回答 2

8

是否可以通过代码检测该标志?

是的。

在 API Doc 中,它被称为Settings.System.ALWAYS_FINISH_ACTIVITIES

如果为 1,活动管理器将在不再需要活动和流程时积极完成它们。如果为 0,则使用正常的延长寿命。

常数值:“always_finish_activities”

要获取代码中的值:

int value = Settings.System.getInt(getContentResolver(), Settings.System.ALWAYS_FINISH_ACTIVITIES, 0);

查看源代码以了解 Settings.apk 是如何做到的。

于 2012-08-09T22:35:04.537 回答
1

我不确定你能做到,正如我回答别人的那样,你为什么要这样做?您当然不应该使用该标志来更改应用程序的行为。

不保持活动?

于 2012-08-09T16:23:15.010 回答