I have some conditional calls from my code which starts same service with different data values passed through bundle to that service. When I checked for only one condition met, service works fine for all conditions. But when 2 or more conditions match, these calls this same service but with different data values in bundle. Problem is when this scenario is met the values sent by first call are not getting replaced for second condition to start same service. So service is responding wrongly.
It is like this
if(some cond)
{
some values in serivce intent bundle.startService(serviceintent1);
}
if(some cond)
{
some data in intent bundle.startService(serviceintent1);
}
When both conditions are met then call to startService is twice. but I am getting values from first condition in second condition startService call.
Help me in this issue...
What is your return type in onStartCommand ?
You should read about the life cycle of the service. https://developer.android.com/reference/android/app/Service.html#ServiceLifecycle
I would suggest to use IntentService, as it is designed for handling asyncron tasks, it also start in a worker thread. http://developer.android.com/reference/android/app/IntentService.html
To really help you, the code of your service is quite important :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With