sending data from activity to Intentservice

☆樱花仙子☆ 提交于 2021-01-27 13:26:56

问题


my needs is to send data from activity to IntentService

(from class that extends activity, to class that extends IntentService)

i successed to send to sample service, by using BroadcastReciver, but i want to extend IntentService class and not service

someone know how can i do that?

from

public class MainActivity extends Activity { ... }

to

public class MyIntentService extends IntentService { ... }


回答1:


Put the data in an Intent extra that you use with the startService() call to start your IntentService. Then, the IntentService can read that extra in onHandleIntent().



来源:https://stackoverflow.com/questions/18300996/sending-data-from-activity-to-intentservice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!