Reputation: 13
I am using IntentService in my application. I want to know that, Is this Necessary to putExtras() before calling to startService(intentService) Method. Or can i call the startService(intentService) without providing data to intent. I want to know the reason behind this concept.
Thanks in advance.
Upvotes: 0
Views: 104
Reputation: 139
No. It is not needed. If you want to pass some values to the activity which is started by Intent then only you need to use putExtras(). Otherwise use can start activity using startActivity(intent) without implementing putExtras()
Upvotes: 0
Reputation: 14590
Is this Necessary to putExtras() before calling to startService(intentService)??
Answer is No.
putExtras()
is used to pass the data between Activitys
and Services
.if you want send some data to Service then Use putExtras()
The same intent here in IntenetService
will received onStartCommand(Intent intent, int flags, int startId)
get the data from the intent using getExtras()
method
Upvotes: 1