Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在AlarmManager重复Android中限制时间_Android_Alarmmanager - Fatal编程技术网

如何在AlarmManager重复Android中限制时间

如何在AlarmManager重复Android中限制时间,android,alarmmanager,Android,Alarmmanager,我使用ArlamManager创建提醒 AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),10000,sender); 现在我想将重复的时间从现在(2013年6月20日)限制为两天(2013年6月22日) 谢谢可能还有其他方法可以做到这一点,但我想到的第一件事是检

我使用ArlamManager创建提醒

AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);

am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),10000,sender);
现在我想将重复的时间从现在(2013年6月20日)限制为两天(2013年6月22日)


谢谢

可能还有其他方法可以做到这一点,但我想到的第一件事是检查您的
接收器
s
onReceive()
方法中的日期。如果日期<目标日期,则运行代码,如果不是,则取消报警

设置报警时,请在
SharedReference
中设置希望报警停止的日期,并在运行代码之前检查该日期

@Override
public void onReceive(Context context, Intent intent) 
{
    SharedPreferences datePref = context.getSharedPreferences("stopDate", 0);
    // get the current date hear using a Calendar Object and compare it to datePref
    if (datePref < currentDate)
    {
        ...
    }
    else
    {
      //  recreate the PendingIntent and cancel the alarm with AlarmManagers cancel() funciton
    }
@覆盖
公共void onReceive(上下文、意图)
{
SharedReferences datePref=context.getSharedReferences(“stopDate”,0);
//使用日历对象获取当前日期并将其与datePref进行比较
如果(日期优先<当前日期)
{
...
}
其他的
{
//使用AlarmManager cancel()函数重新创建PendingEvent并取消报警
}

我不明白你的问题..请解释清楚\n你可以在两天内注册另一个闹钟播放,当该播放时删除另一个。