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.
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);
You can send a
Home key event via
Home should put an Activity to the background:
adb shell input keyevent 3
from the docs:
public static final int KEYCODE_HOME Added in API level 1
Key code constant: Home key. This key is handled by the framework and
is never delivered to applications. Constant Value: 3 (0x00000003)
possible values: http://developer.android.com/reference/android/view/KeyEvent.html
more to-the-point list:
ADB Shell Input Events
appium_liband I write
background_app 8 to minimize and have the application running in the background. 8 is the number of seconds you will want to keep it minimized.