通过PendingIntent检查警报始终返回null,但是设置了警报

问题描述

|| 我正在设置警报,每2分钟运行一次服务。我还在其他地方检查该警报是否已设置。但是,我对警报的检查总是返回false(未设置),但是如果我在服务中放了一个断点,那么肯定在2分钟内就会触发它。因此,警报已设置,但我无法告知。 这是我用来设置警报的代码
public void setWakeUpFromNow(long millisecFromNow) {
    Intent i = new Intent(mContext,OnWakeUpReceiver.class);

    PendingIntent pIntent = PendingIntent.getbroadcast(mContext,i,PendingIntent.FLAG_ONE_SHOT);

    Calendar Now = Calendar.getInstance();

    mAlarmManager.set(AlarmManager.RTC_WAKEUP,Now.getTimeInMillis() + millisecFromNow,pIntent);

 }
这是我检查是否已设置的地方
 public boolean isWakeUpSet() {
    Intent i = new Intent(mContext,PendingIntent.FLAG_NO_CREATE);   

    return pIntent != null;
 }
即使稍后唤醒OnWakeUpReceiver,isWakeUpSet始终返回false。     

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)