How do I get data within an Android Service that was passed from an invoking Activity?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
This is a much better and secured way. Working like a charm!
instead of :
Because when you try 2nd one then you get an error saying : java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.floatingwidgetchathead_demo.SampleService.ACTION_START }
Then your Service be like this :
Pass data from Activity to IntentService
This is how I pass data from
Activity
toIntentService
.One of my application has this scenario.
MusicActivity ------url(String)------> DownloadSongService
1) Send Data (Activity code)
2) Get data in Service (IntentService code)
You can access the intent in the
onHandleIntent()
method