I am trying to call a push notification background service from BroadcastReceiver class, but my application crashes. The code is given below:
public class AlarmReceiver extends BroadcastReceiver {
static int count=1;
@Override
public void onReceive(Context context, Intent intent) {
Intent myIntent=new Intent(context,NotifyService.class);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myIntent);
}
}
The manifest entry:
<receiver android:name=".AlarmReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<service android:name=".NotifyService">
</service>
The error:
05-24 15:17:00.042: ERROR/AndroidRuntime(424): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.alarm/com.android.alarm.NotifyService}; have you declared this activity in your AndroidManifest.xml?
When I call this service through an Activity it's working, but my goal is to call this service from a BroadcastReceiver.