2014-03-31 40 views
1

在我AndroidManifest.xml中我有以下的發射活動(我只是添加了第二個活動,以默認的項目):無法從亞行

<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> 

我想用ADB命令來啓動測試活動。我想:

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

但它給人的錯誤:

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

是否有人可以解釋爲什麼我收到此錯誤以及如何解決它?

編輯:

誰能告訴一個辦法只有用行動來推出的「測試活動」。

回答

0

嘗試adb shell am start -n com.mypackage.name/com.mypackage.name.TEST_ACTION(更換包裝名稱和活動名稱爲需要)

this solution看看。

1

嘗試使用: adb shell "am start -n com.example.com.testapp/.TestActivity -a com.testapp.action.TEST_ACTION"

adb shell "am start com.example.com.testapp -a com.testapp.action.TEST_ACTION"

希望工程。

+0

的第一個作品。爲什麼我不能只用動作來開始活動? – Jake

+0

第一種情況不需要動作部分。 – Jake

+0

您必須選擇活動才能運行與該活動相關的操作。 –

2

我想你應該添加以下代碼到你的IntentFilter

<category android:name="android.intent.category.DEFAULT"/>