Attach Android app to background

Is it possible to attach an application to the background using the adb command? I have an application that invokes Google navigation, and I want to steer Google navigation into the background with the adb command. I don’t want to just return to the main screen, I want to make sure that the application called google navigation remains in the foreground. So far, I:

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

But the aforementioned team power stops the process instead of clicking on the background.

+6
source share
3 answers

As CommonWare commented, instead of pushing another application to the background, you can bring your application to the forefront by calling startactivity and setting the appropriate flags.

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

You can send the Home event using adb by clicking Home , you should put the operation in the background:

adb shell input key 3

from documents:

public static final int KEYCODE_HOME Added to API level 1

Key code constant: master key. This key is processed 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 accurate list: ADB I / O events

+6
source

I am using appium_lib and I am writing background_app 8 to minimize and run the application in the background. 8 is the number of seconds you want to keep at a minimum.

+1
source

Source: https://habr.com/ru/post/948025/


All Articles