【发布时间】:2011-06-13 14:59:20
【问题描述】:
我使用警报服务跳转到服务。当服务启动时,我怎样才能找回意图(我想从意图中获取数据)? 我的代码如下
PendingIntent sender=PendingIntent.getService(this, 0, myIntent, 0);
am = (AlarmManager)getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), sender);
如何从服务中取回“myIntent”?没有像 getIntent() 这样的方法 在服务中。我尝试在 onBind(Intent intent) 中使用意图,但这不是我想要的。
我想我解决了这个问题。 PendingIntent 发件人=PendingIntent.getService(this, 0, myIntent, PendingIntent.FLAG_ONE_SHOT);
问题是关于标志的。现在我可以在服务类中恢复我的意图 OnStartCommand(Intent,int,int)
【问题讨论】:
-
对不起,这完全没有意义。添加该标志应该完全没有改变。这充其量是误导。
标签: android service android-intent alarmmanager android-pendingintent