Launching an external activity from Receiver
I got this this code to launch Googles Car Home:
Intent i = new Intent();
i.setClassName("com.android.carhome", "CarHome");
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
contex开发者_C百科t.startActivity(i);
However, I got following error:
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
How do I declare this in the anifest? I googled quite a lot, but didn't find the answer.
Thanks!
This is how you declare Receiver in your manifest.
<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
However, I'm not sure if you can start external intent as receiver. You must start it as separate activity with DEFAULT category and all that stuff.
精彩评论