ADB to Launch android browser with given url - android

I am trying to send a commend via ADB to launch different browsers with a given URL.
I only know the package names of the browsers so I used:
adb shell monkey -p com.android.chrome -c android.intent.category.LAUNCHER 1
This way I could open the app with only the package name, but I couldn't pass any URL to it.
I could pass a URL to chrome using:
adb shell am start -a android.intent.action.VIEW -d https://www.bbc.com/
but this requires more then just package name.
Trying to combine these two didn't work:
adb shell monkey -p com.android.chrome -c android.intent.category.LAUNCHER 1 -d https://www.yahoo.com
What is the correct way to pass a URL to a browser using only the package name with monkey?
Thank you all!

adb shell am start -a android.intent.action.VIEW -d http://www.facebook.com

Related

Android ADB Open URL in current tab/close previous tabs

I am currently using the following to open a tab in the native browser on an android device
adb shell am start -a "android.intent.action.VIEW" -d "http://google.co.uk"
The issue I have is that each time the command is sent it open a new tabs. To combat this I have tried to kill the browser in an attempt to start again howevre, the previous tab are remembered.
adb shell am force-stop com.android.browser
I did previously try a kill, but this did not seem to work
adb shell am kill com.android.browser
I did some quick reading and found the option create_new_tab but I believe this to be for chrome and not the native browser.
adb shell am start -a "android.intent.action.VIEW" -d "http://google.co.uk" --ez create_new_tab false
Does anyone know how a single tab can be used and either open a tab if one does not exist, or use the existing one if it does. I am using windows command line.
I was able to reuse the same browser tab with the following command:
adb shell am start -a "android.intent.action.VIEW" -d "http://www.google.com" --es "com.android.browser.application_id" "com.package.name"
Some documentation can be found here:
https://developer.android.com/reference/android/provider/Browser.html#EXTRA_APPLICATION_ID

adb "am start -n" not working for debug version

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/)

Open Chrome with ADB

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

How to launch android gallery app using adb shell?

I tried a lot and got
adb shell am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity
for launching browser so I tried the same with gallery and I'm stuck with this
adb shell am start -a android.intent.action.MAIN -n com.sec.android.gallery3d/.GalleryActivity</b><br/>
I know GalleryActivity is not available but what else can i use?
Note: I am using samsung Galaxy S3 mini so the package name is com.sec.android.gallery3d
We can use monkey to open any app through adb shell,
Try the below command,
$ adb shell monkey -p com.android.gallery3d 1
In my nexus4, Gallery app package name is com.android.gallery3d and we are just passing 1 event via monkey, So that monkey will just open the app and will not do anything further.
Also this approach helps you to open any app just with the package name. Monkey will pick the launcher activity by itself.
Hope it helps.
maybe
adb shell am start -t image/* -a android.intent.action.VIEW
also one more thing , this will open the default app selected for gallery in your device.

Android: launch app info dialog via adb shell am

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.

Categories

Resources