开发者

Android PendingIntent howto

开发者 https://www.devze.com 2023-02-27 07:11 出处:网络
Ok I am stuck. Can someone please point me in the right direction? I have no idea where to start with pendingintents. I need to start custom service that sends some dat开发者_JAVA百科a back to the act

Ok I am stuck. Can someone please point me in the right direction? I have no idea where to start with pendingintents. I need to start custom service that sends some dat开发者_JAVA百科a back to the activity that started it. How would I do that?


I would probably register a Broadcast Receiver in my Activity and if I needed to communicate from Service to Activity, send a broadcast from the Service and the Activity's receiver would pick it up as long as the Activity was currently running. This, by the way, would not require the use of a PendingIntent. PendingIntents are more used with alarms from the AlarmManager or with Notifications.


You should consider using AsyncTask if you expect your Activity to be active (visible) all the time the Service runs.

0

精彩评论

暂无评论...
验证码 换一张
取 消