重启后接收器不起作用

时间:2015-06-13 16:53:37

标签: android receiver

重新启动或打开设备后,我的接收器无法正常工作。 当我没有重启或打开我的设备时,他们正在工作......

清单:

    <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>

广播接收器:

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);
}

的活动:

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 个答案:

没有答案