How do I prevent using startActivityForResult in an activity from thinking it went to the background in the ApplicationLifecycleHandler?
Asked
Active
Viewed 147 times
0
-
Are you starting one of your activities, or an activity from a third-party app? – CommonsWare Mar 10 '16 at 18:27
-
@CommonsWare it opens an activity to select your image so i guess a 3rd party app – Tim Nuwin Mar 10 '16 at 18:48
1 Answers
1
If you call startActivityForResult()
, and it is starting up an activity that is not yours, then your app is moving to the background, and so the TRIM_MEMORY_UI_HIDDEN
value is correct.

CommonsWare
- 986,068
- 189
- 2,389
- 2,491
-
-
1@TimNuwin: It may be that the correct answer is for you to switch to `TRIM_MEMORY_BACKGROUND` instead of `TRIM_MEMORY_UI_HIDDEN` all the time. If you're sure that you normally want to use `TRIM_MEMORY_UI_HIDDEN`, then you'll have to use a flag (set in `startActivityForResult()`, cleared in `onActivityResult()`) indicating that this third-party activity was launched, so you change your `onTrimMemory()` algorithm to accommodate that. However, bear in mind that the user might switch to something else entirely after you launch the image picker. – CommonsWare Mar 10 '16 at 19:00