Receiver doesn't work after restart

132 views Asked by At

After i restart or turn on my device my receivers don't working. When i don't restart or turn on my device they are working...

Manifest:

    <receiver
        android:name=".AlarmReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

    <receiver
        android:name=".ActionReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

BroadcastReceiver:

public void onReceive(Context context, Intent intent) {
        String msg=intent.getStringExtra("msg");
        String note=intent.getStringExtra("note");

        Intent startIntent = new Intent(context, alarmDialog.class);

        startIntent.putExtra("msg",msg);
        startIntent.putExtra("note",note);
        startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(startIntent);
}

Activity:

Intent intent = new Intent(addOne.this,AlarmReceiver.class);
intent.putExtra("msg", title.getText().toString());
intent.putExtra("note", note.getText().toString());

AlarmManager alarmMgr=(AlarmManager)getSystemService(Context.ALARM_SERVICE);
PendingIntent alarmIntent = PendingIntent.getBroadcast(getApplicationContext(), id, intent,     PendingIntent.FLAG_UPDATE_CURRENT);
alarmMgr.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), alarmIntent);
0

There are 0 answers