Я пытаюсь вызвать фоновую службу push-уведомлений из класса BroadcastReceiver, но мое приложение вылетает. Код приведен ниже:
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);
}
}
Запись манифеста:
<receiver android:name=".AlarmReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<service android:name=".NotifyService">
</service>
Ошибка:
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?
Когда я вызываю этот сервис через Activity, он работает, но моя цель - вызвать этот сервис из BroadcastReceiver.