Force
Force

Reputation: 6382

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);
                context.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!

Upvotes: 0

Views: 222

Answers (1)

Nikola Despotoski
Nikola Despotoski

Reputation: 50538

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.

Upvotes: 1

Related Questions