Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot launch activity from adb

Tags:

android

I have the following in my AndroidManifest.xml (I just added a second activity to the default project):

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
    android:name="com.example.com.testapp.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

</activity>
<activity
    android:name="com.example.com.testapp.TestActivity"
    android:label="@string/title_activity_test" >
    <intent-filter>
        <action android:name="com.testapp.action.TEST_ACTION" />
    </intent-filter>
</activity>

I want to launch the TestActivity using adb command. I tried:

./adb shell am start -a com.testapp.action.TEST_ACTION

But it gives the error:

 Error: Activity not started, unable to resolve Intent { act=com.testapp.action.TEST_ACTION flg=0x10000000 }

Can someone please explain why I am getting this error and how to resolve it?

Edit :

Can anyone tell a way to just use action to launch the 'TestActivity'.

like image 713
Jake Avatar asked Dec 19 '22 16:12

Jake


1 Answers

I think you should add the code below into your intentfilter

<category android:name="android.intent.category.DEFAULT"/>
like image 122
陈薛星 Avatar answered Jan 01 '23 08:01

陈薛星