Android - start an activity from command line using intent uri
Solution 1
You need to use ""
:
adb shell 'am start "intent:#Intent;scheme=customapp;package=com.comp.pac;end"'
Solution 2
enter code hereAnother way to open activity :
$ adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android
Solution 3
Another way to run an Activity from the shell:
adb shell am start com.example.hello/.MainActivity
Note the "/" after the package
name and the "." before the Activity
name.
Comments
-
500865 almost 3 years
I have an Activity A with the following intent filter
<activity android:name="com.comp.pac.ActivityA"> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:scheme="customapp" android:host="show" android:path="/"/> </intent-filter> </activity>
I am basically trying the custom data scheme in intent filters as explained here
To test whether the IntentUri launches the activity or not I'm trying to fire the intent using the following command through terminal :
adb shell am start intent://show/#Intent;scheme=customapp;package=com.comp.pac;end
I get the following error :
Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=intent://show/ flg=0x10000000 }
Question : Is there anything wrong with the command? If not, what is the easiest way to test whether the intent uri starts the activity?
The instructions for using the
adb
command to start activity using intent uri is available here.