Bringing the ActivityManager to "No longer needed" for testing

I am trying to check how my application handles the destruction of Android ActivityManager (and later is restarted by Alarm events). In other words, I want to force the message:

 I/ActivityManager( 333): No longer want com.myname.myapp (pid 4444): hidden #22 

Is there a way to reliably call an ActivityManager in the "No longer needed" of my application?


A few tricks that I know for completing processes (however, the goal of this question is to find something to call the ActivityManager β€œNo More Need” method).

  • Using Application Management, click the Power Stop button.
    The problem with this is that it does not always look the same as the ActivityManager β€œNo ActivityManager ” method.
  • Launch many memory lock applications.
    The problem with this is unreliable and time-consuming. Sometimes I can run many applications, and I do not see the peep from the ActivityManager .
  • OS API killBackgroundProcesses() .
    The problem with this is that it was unclear whether the explicit call to killBackgroundProcesses() behave explicitly in the same way as the ActivityManager β€œNo killBackgroundProcesses() ” method.
+7
source share
1 answer

The new version of Android has the option "Do not perform actions." After choosing that each action will be destroyed as soon as the user leaves the Activity. For example, we have activity A and B. Normal flow

  • Activity A starts activity B

After selecting Do not perform actions

  • Activity Initial Activity B
  • B β†’ onCreate, A β†’ onDestroy (note that A does not cause completion after starting activity B)
  • Pressing the back button will return you to Activity A
0
source

All Articles