开发者

How do I send some data (eg. a String) from my Activity to a Service ...in Android?

Usually, I putExtra inside an Intent to transfer stuff between Activities.

But it seems like I can't do this with a Service?

Bundle extras = getIntent().getExtras();

That doesn't work for a android Service. How do I send a stri开发者_开发百科ng from an Activity to a Service then?


The same way as you did with the Activity. You will get the Intent in the onStart() callback method, which you would need to override. That will be called whenever a client calls startService() for your Service, supplying the Intent in question.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜