I am running an app from ADB shell like this:
adb shell am start -n mypackage/.MainActivity
I need to terminate the app automatically after 10 seconds and start another application.
I am trying to do something like this:
adb shell timeout -t 10 am start -n mypackage/.MainActivity
But unfortunately this does not work.
Output:
/system/bin/sh: timeout not found
Is there any way to make this work?
Use following
start adb shell am start -n mypackage1/.MainActivity
timout /t 10
kill mypackage1
start adb shell am start -n mypackage2/.MainActivity
More Info here
You can use sleep command running on the device itself:
adb shell "am start -W -n mypackage1/.MainActivity; sleep 10; am force-stop mypackage1"
adb shell "am start -W -n mypackage2/.MainActivity"
It seems that the app you are trying to start/stop is not designed properly. In this case do:
adb shell "(sleep 10; am force-stop mypackage1) & am start -n mypackage1/.MainActivity"
adb shell "am start -n mypackage2/.MainActivity"
Related
I tried below commands for making outgoing call using ADB command and it's working
adb -s XYZWER56RITYDFS shell am start -a android.intent.action.CALL -d tel:555-5555
But not able to put call on HOLD I tried below command but its not working
adb -s XYZWER56RITYDFS shell am start -a android.intent.action.ON_HOLD
How can I achieve this using any adb keyevent or adb command to put ongoing call on hold.
I am trying to use adb to launch activites for testing,But it does not work for the debug version :
This works
adb shell am start -n com.xx.xx/.main.ParentActivity
This doesn't
adb shell am start -n com.xx.xx.debug/.main.ParentActivity
Both debug and release packages are available under /data/data
If you have class com.xx.xx.main.ParentActivity and your application id is com.xx.xx.debug then you have to specify FQCN like this:
adb shell am start -n com.xx.xx.debug/com.xx.xx.main.ParentActivity
Dot just after slash is shortcut which can be used only if FQCN starts with application id.
use adb shell am start -D -n com.xx.xx.debug/.main.ParentActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
then you will be able to attach your debugger (via your IDE) and the app will start (see https://blog.jetbrains.com/idea/2011/05/new-in-105-attach-debugger-to-a-running-android-process/)
I used to able to launch Chrome using ADB like this:
adb shell am start -n com.android.chrome/com.android.chrome.Main
But now when I try it, I get:
Starting: Intent { cmp=com.android.chrome/.Main }
Error type 3
Error: Activity class {com.android.chrome/com.android.chrome.Main} does not exist.
It seems that the Main Class name has changed. If so, what's the new one?
Adb command for this
adb shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
To open the default page of Chrome with ADB you can use:
adb shell am start -n com.android.chrome/com.google.android.apps.chrome.Main
Instead, to open an url directly you can use:
adb shell am start -n com.android.chrome/com.google.android.apps.chrome.Main -d "www.facebook.com"
adb shell
webview with default browser:
am start -a android.intent.action.VIEW -d https://www.google.com/
Firefox:
monkey -p org.mozilla.tv.firefox -c android.intent.category.LAUNCHER 1
Chromium:
monkey -p org.chromium.chrome -c android.intent.category.LAUNCHER 1
Android activity is launched from adb shell by the command am start -n packagename/.activityname
When the activity is started it is displaying the status stating the android activity ... in the adb shell
How to supress that output into adb shell
Use linux- redirect the output to /dev/null.
am start -n packagename/.activityname > /dev/null
I'm trying to write a script which will launch the "app info" system dialog via adb for an app I'm testing.
I have done some investigation and came up with this command, which will launch "app info" but fails with a force close (NullPointerException in logcat):
adb shell am start -a android.intent.action.VIEW -n com.android.settings/.applications.InstalledAppDetails -es com.android.settings.ApplicationPkgName com.my.app -es pkg com.my.app
Seems that the package name isn't being properly passed.
What is the correct way to pass the package name parameter to the am command in this case?
adb shell am start -a android.settings.APPLICATION_DETAILS_SETTINGS -d package:<package-name>
Also, check this: https://stackoverflow.com/a/4567928/4409113
adb shell am start -n com.package.name/com.package.name.ActivityName
http://developer.android.com/tools/help/shell.html#am
You can also issue an activity manager command directly from adb
without entering a remote shell.
For example:
adb shell am start -a android.intent.action.VIEW
Seems like, start -a is a good way.