我一直试图做一个定时通知而它只是不起作用,帮忙?
设置闹钟:
Intent intent = new Intent(context, MyAlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent,0);
AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC, calendar.getTimeInMillis(), pendingIntent); //calendar is declared and taking it's values from a time picker
接收器:
public class MyAlarmReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
Log.wtf("ddd", "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII");
Intent service1 = new Intent(context, MyAlarmService.class);
context.startService(service1);
}
}
清单:
<receiver android:name="MyAlarmReceiver" >
<intent-filter>
<action android:name="REFRESH_THIS" />
</intent-filter>
</receiver>