Search code examples
androidadb

Push android application to background


Is it possible to push an application to the background through an adb command? I have an application which calls google navigation and I want push google navigation to the background using an adb command. I don't want to just go back to the home screen, I want make sure the app which called google navigation remains on the foreground. So far I have:

adb shell am force-stop com.google.android.apps.maps

But the above command force stops the process instead of pushing to background.


Solution

  • As CommonWare commented, Instead pushing the other app to background you can bring your app to foreground by calling startactivity and by setting appropriate flags.

    Intent i = new Intent(context, YourActivity.class);
    i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    startActivity(i);