0

How do I prevent using startActivityForResult in an activity from thinking it went to the background in the ApplicationLifecycleHandler?

Tim Nuwin
  • 2,775
  • 2
  • 29
  • 63

1 Answers1

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
  • How should i go about making an exception for the image picker? – Tim Nuwin Mar 10 '16 at 18:52
  • 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