androidshellandroid-intentandroid-manifestexplicit-intent

open specific Activity from command line


I'm trying to start a specific Activity from command line. I'm building the app for Android O (api 26), and i try to explicitly start that activity to simulate a deeplink

the activity manifest

<activity
        android:name=".activities.ChatActivity"
        android:label="@string/chat_action_bar_title"
        android:launchMode="singleTask"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </activity>

my package is: package="com.my.app"

and i m useing this command:

adb shell am start  -n com.my.app.activities/.ChatActivity

and i m getting this error:

    Starting: Intent { cmp=com.my.app.activities/.ChatActivity }
Error type 3
Error: Activity class {com.my.app.activities/com.my.app.activities.ChatActivity} does not exist.

I tried to add

 -a android.intent.action.VIEW

and

-c android.intent.category.DEFAULT

but i cant start that activity,

what am i doing wrong?


Solution

  • So after hours of seeking the unknown i have found the solution. In my app i m using some BuildVariants to differentiate working phases.

    so instead of using the command

    adb shell am start  -n com.my.app.activities/.ChatActivity
    

    I should of used

    adb shell am start -n com.my.app.MY_BUILD_VARIANT/com.my.app.activities.ChatActivity
    

    thanks for the helpers