Alarm Receiver 使用 Intent无法更新值的解决方法

来源:互联网 发布:阿里云服务器域名绑定 编辑:程序博客网 时间:2024/06/05 17:58
 

Alarm Receiver 使用 Intent无法更新值的解决方法


在新建PendingIntent时,指定Flag: FLAG_UPDATE_CURRENT

如:
PendingIntent sender=PendingIntent.getBroadcast(
                 myActivity.this,0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

I am using marks' method of alarmreceiver and appservice. I am trying
to pass a record id to the alarmintent through putextra. and receive
it in ontimealarmreceiver in getExtra.

What I observe is, first time record id goes correct (say 11) second
time record id is sent 12, but in receiver i receive record id = 11.
third time too record id -11


whats wrong ?


regards

 


 
  

   

   
 

您需要先登录才能发帖。
要发帖,您需要先加入此论坛。
请先在订阅设置页上更新您的昵称,然后再进行发帖。
您没有发帖的权限。
    
  
Mark Murphy    查看个人资料   翻译成中文(简体) 翻译内容(查看原文内容) 
  更多选项 2009年12月17日, 下午7时52分 

发件人:"Mark Murphy" <mmur...@commonsware.com>
日期:Thu, 17 Dec 2009 06:52:12 -0500 (EST)
当地时间:2009年12月17日(星期四) 下午7时52分
主题:Re: [android-developers] wrong intent getting supplied to OneTimeAlarmReceiver.
打印 | 单个帖子 | 显示原始帖 | 举报此帖 | 查找此作者的帖子

> I am using marks' method of alarmreceiver and appservice. I am trying
> to pass a record id to the alarmintent through putextra. and receive
> it in ontimealarmreceiver in getExtra.

> What I observe is, first time record id goes correct (say 11) second
> time record id is sent 12, but in receiver i receive record id = 11.
> third time too record id -11


> whats wrong ?

 

PendingIntent recycles Intents, in effect. Try specifying
FLAG_UPDATE_CURRENT when you create your PendingIntent.


--
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html

 

http://groups.google.com/group/android-developers/browse_thread/thread/d3507afeda5f33ba#