0

我使用警报服务跳转到服务。当服务启动时,我怎样才能找回意图(我想从意图中获取数据)?我的代码如下

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) 上找回我的意图

4

1 回答 1

0

如何从服务中取回“myIntent”?

它作为参数传递给onStartCommand()(如果这是一个IntentService,也传递给onHandleIntent())。

于 2011-06-13T16:20:50.403 回答