samedi 21 juillet 2018

How to test a system service kill?

I have an Android Service that runs 24/7 in the background. It does this by returning START_STICKY from onStartCommand(), but on some devices, the Android system kills the service after a while (6 or so hours), and even START_STICKY cannot save it.

To solve this problem, I've decided to try using a Broadcast receiver that restarts my service in onDestroy(), but I have no way to test this solution:

   @Override
public void onDestroy() {
 sendBroadcast(broadcastIntent); //This receiver restarts my service!
}

How can I stimulate the system killing my service so that I can test my solution?

I've seen this and this, but neither posts help since START_STICKY works in those situations. Is there some sort of ADB command to trigger a system service wipe or something?

Aucun commentaire:

Enregistrer un commentaire