How to start an application using Android ADB tools
adb shell
am start -n com.package.name/com.package.name.ActivityName
Or you can use this directly:
adb shell am start -n com.package.name/com.package.name.ActivityName
You can also specify actions to be filter by your intent-filters:
am start -a com.example.ACTION_NAME -n com.package.name/com.package.name.ActivityName
Start application on phone from ADB
If you install the app AppXplore from Google Play, you can inspect your installed applications and learn the package name and the Activities in the APK.
I've verified it just now and it worked by starting Adobe Reader from adb shell:
am start -n com.adobe.reader/com.adobe.reader.AdobeReader
Launch App via adb without knowing Activity name
Yes, it is possible to launch an app via adb shell making use of the monkey tool.
Using the command from this answer:
adb shell monkey -p app.package.name -c android.intent.category.LAUNCHER 1
This command simulates the app icon click, so the intent implicit intent LAUNCHER is delivered to the specific receiver declared in app manifest (MAIN)
How to start an Android application from the command line?
adb shell
am start -n com.package.name/com.package.name.ActivityName
Or you can use this directly:
adb shell am start -n com.package.name/com.package.name.ActivityName
You can also specify actions to be filter by your intent-filters:
am start -a com.example.ACTION_NAME -n com.package.name/com.package.name.ActivityName
How to launch my Android application using adb shell?
You should escape the $ - \$
- since otherwise it gets changed to nothing. $WDLanceor
is interpreted as a shell variable by the android shell, and since the variable is not set it becomes an empty string.
Quoting the arguments (adb ... -n "... GWDPSupaScale_Android$WDLanceur"
) will only quote it on the Windows side, when it goes into the shell on the android side it'll be without quotes. The backslash will survive the Windows command prompt and be converted to an actual $ on the android shell.
Is it possible to start activity through adb shell?
Launch adb shell and enter the command as follows
am start -n yourpackagename/.activityname
Start Android APK with args from adb
First, How can I get args in OnCreate method?
That is not possible, in the terms that you describe.
Then with adb, How can I run my application with those args?
That is not possible, in the terms that you describe.
What you can do — and what the adb
example shows you — is supply Intent
extras:
adb shell am start -S -D com.example.apk/android.app.MainActivity --es args '"-name MYNAME -email test@gmail.com"'
This is not a particularly good way to use Intent
extras, but let's start with it.
Here, you are passing a string extra named args
with a value of "-name MYNAME -email test@gmail.com"
.
In onCreate()
of your activity, you could call getIntent().getStringExtra("args")
to retrieve that string:
String args = getIntent().getStringExtra("args");
Now, the args
variable will hold -name MYNAME -email test@gmail.com
.
A simpler and cleaner adb shell am start
command would be:
adb shell am start -S -D com.example.apk/android.app.MainActivity --es name MYNAME --es email test@gmail.com
Now you are passing two string extras, name
and email
. You can then retrieve each value individually:
String name = getIntent().getStringExtra("name");
String email = getIntent().getStringExtra("email");
Related Topics
How to Start New Activity on Button Click
Building and Running App Via Gradle and Android Studio Is Slower Than Via Eclipse
Imageview in Circular Through Xml
How to Find Out If the Gps of an Android Device Is Enabled
Is the Way the Firebase Database Quickstart Handles Counts Secure
How to Create an Object of an Activity in Other Class
How to Pass Data Between Fragments
"Debug Certificate Expired" Error in Eclipse Android Plugins
How to Change Progress Bar'S Progress Color in Android
How to Get Complete Address from Latitude and Longitude
Changing API Level Android Studio
How to Restart Activity in Android
Can an Android Toast Be Longer Than Toast.Length_Long
"Android.View.Windowmanager$Badtokenexception: Unable to Add Window" on Buider.Show()