Search code examples
androidandroid-intentadbintentfilterurl-scheme

Android - start an activity from command line using intent uri


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.


Solution

  • You need to use "":

    adb shell 'am start "intent:#Intent;scheme=customapp;package=com.comp.pac;end"'