我正在编写一个应用程序,一旦到达特定的日期/时间,它将触发特定的方法。但是,我的广播接收器没有触发...我可以看到闹钟已设置。
我在活动中的方法:
private void setAlarm(Date date){
Intent activate = new Intent(this, Alarm.class);
AlarmManager alarms ;
Calendar cal = new GregorianCalendar();
cal.setTimeInMillis(date.getTime());
PendingIntent alarmIntent = PendingIntent.getBroadcast(this, 0, activate, 0);
alarms = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
Log.d("ALARM","Setting alarm");
alarms.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmIntent);
Log.d("ALARM","Setting time "+cal.getTimeInMillis());
}
我的BroadcastReciever:
public class Alarm extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("ALARM", "RING RING");
}
}
我在<application>
标记内的清单:
<receiver android:name=".Alarm" android:process=":remote" >
<intent-filter>
<action android:name="com.package.feature.subpackage.arrangealarm.ALARM_ACTION"/>
</intent-filter>
</receiver>
有人知道为什么不触发吗?
答案 0 :(得分:1)