I have a question about IntentService in Android. I define my own service as below:
public class ABC extends IntentService implements SensorEventListener {
@Override protected void onHandleIntent(Intent intent) { }
@Override public void onSensorChanged(SensorEvent event) { } }
Now if i start the service from other activity, onHandleIntent() is invoked. Documentation says it launches a worker thread to process the request. However, when onSensorChanged() method is invoked, which thread will be executing the code defined in onSensorChanged() method. Will it be the worker thread or the main application thread???
Per the IntentService source code, IntentServices stop themselves when they no longer have any messages (the
stopSelf
call). Therefore if you want a long runningService
(which I assume would be appropriate for yourSensorEventListener
), then you should use a regularService
.