I am sending intent to a broadcast receiver like this.
Intent cpIntent = new Intent();
cpIntent.setClassName("com.android.contacts", "com.android.contacts.EABContactsAppReceiver");
cpIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
cpIntent.setAction(IMS_SUBSCRIBE);
cpIntent.putExtra("contactid",contactid);
startActivity(cpIntent);
and at the receiver end I am accepting the intent as follows :
else if( intent.getAction().equals(ContactsListActivity.IMS_SUBSCRIBE )){
// this is a dummy event just to start the application
Log.d("ContactsAppReceiver", "IMS_SUBSCRIBE");
final String id = intent.getStringExtra("contactid");
Log.d(TAG,"id :"+id);
I have also declared the activity and the intent filter in Manifest
file.
<receiver android:name="com.android.contacts.EABContactsAppReceiver">
<intent-filter>
<!-- <action android:name="com.sec.android.app.sns.action.UPDATE_ACTIVITY" />
--> <!--<action android:name="com.sec.siso.imsservice.IMS_SERVICE_READY_EVENT" />-->
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.ACTION_SYNC_STATE_CHANGED"/>
<!-- <action android:name="com.sec.android.app.sns.action.UPDATE_MESSAGE" />
-->
<action android:name="com.sec.siso.SUBSCRIBE"/>
<action android:name="com.sec.siso.logs.SUBSCRIBE"/>
</intent-filter>
</receiver>
However I am still getting ActivityNotFoundException
. Can anyone help me on this?
In your first code, you're trying to start an activity instead of sending a broadcast. You should replace
startActivity(cpIntent);
with
sendBroadcast(cpIntent);