How can I get my intent back from a service that is started by the AlarmManager?
I use an alarm service to jump to a service. when the service starts, hwo can I get the intent back(I want to get data from the intent)? My code is as follows
PendingIntent sender=PendingIntent.getService(this, 0, myIntent, 0);
am = (AlarmManager)getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), sender);
How do I get "myIntent" back from the service? there's no method such like getIntent() in service. I tried to use the intent in onBind(Intent intent), but it is not what I want.
I think I got this porblem solved. PendingIntent sender=PendingInten开发者_Python百科t.getService(this, 0, myIntent, PendingIntent.FLAG_ONE_SHOT);
the problem is about the flag. now I can get my intent back at the service class OnStartCommand(Intent,int,int)
How do I get "myIntent" back from the service?
It is passed as a parameter to onStartCommand()
(and, if this is an IntentService
, also to onHandleIntent()
).
精彩评论