Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 678
500865 Avatar asked Jan 10 '14 00:01

500865


People also ask

What are intents in Android?

In general, Intents are used to progress to the next activity or come back to the previous activity. In this article, we will show you how you could start a New Activity using Intent in Android using Jetpack Compose.

How do I start an activity using intent Uri?

The instructions for using the adb command to start activity using intent uri is available here. Note the "/" after the package name and the "." before the Activity name. $ adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android

How do I start an activity from a URL in Android?

If you want start activity, you write code like this. And If you want launch url page, you will pass Uri with Intent.ACTION_VIEW. If you use many browser in your phone, android will show select browser view for url load. This select view is not only url also any other duplication action.

How to launch URL page using intent in Android?

And If you want launch url page, you will pass Uri with Intent.ACTION_VIEW. If you use many browser in your phone, android will show select browser view for url load. This select view is not only url also any other duplication action. How you can see this select view?


2 Answers

You need to use "":

adb shell 'am start "intent:#Intent;scheme=customapp;package=com.comp.pac;end"'
like image 66
Alex P. Avatar answered Oct 18 '22 01:10

Alex P.


enter code hereAnother way to open activity :

$ adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android
like image 22
Manmohan Avatar answered Oct 17 '22 23:10

Manmohan