2011-08-14 30 views
0

外部活動我得到這個驗證碼推出谷歌汽車主頁:啓動從接收機

Intent i = new Intent(); 
       i.setClassName("com.android.carhome", "CarHome"); 
       i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
       context.startActivity(i); 

但是,我得到了以下錯誤:

E/AndroidRuntime(6604): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.carhome/com.android.carhome.CarHome}; have you declared this activity in your AndroidManifest.xml 

如何聲明這在anifest?我搜索了很多,但沒有找到答案。

謝謝!

回答

1

這就是您在清單中聲明Receiver的方式。

<receiver android:name=".CarHome" android:enabled="true"> 
     <intent-filter> 
     <action android:name="com.android.carhome.CarHome"></action> 
     </intent-filter> 
    </receiver> 

http://developer.android.com/guide/topics/manifest/receiver-element.html

不過,我不知道你是否可以啓動外部意圖爲接收器。您必須將其作爲單獨的活動與DEFAULT類別和所有這些東西一起啓動。

+0

謝謝,但我仍然得到相同的錯誤。我也試着用替換,但那也沒用。 – Force

+0

我不確定您是否可以將外部活動作爲收件人運行。 –