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

mcfly soft
  • 11,289
  • 26
  • 98
  • 202

2 Answers2

8

Is it possible to detect that flag by code ?

Yes.

In API Doc, it is called Settings.System.ALWAYS_FINISH_ACTIVITIES:

If 1, the activity manager will aggressively finish activities and processes as soon as they are no longer needed. If 0, the normal extended lifetime is used.

Constant Value: "always_finish_activities"

To get the value in code:

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

Check out the source code to see how Settings.apk did this.

Community
  • 1
  • 1
yorkw
  • 40,926
  • 10
  • 117
  • 130
1

I am not sure you can and as I answered to someone else, why would you want to? You certainly should not be using that flag to change the behavior of your app.

Don't keep activities?

Community
  • 1
  • 1
Kaediil
  • 5,465
  • 2
  • 21
  • 20
  • I do not want to change that flag I only want to detect that flag as the title says. Is it possible to detect that flag by code ? – mcfly soft Aug 09 '12 at 16:29