I am trying to explore the world of Services
in Android and I just wrote a small example where the activity has a button that triggers a notification.
The steps I do are:
- Creating
Intent intent = new Intent(context, MyService.class);
- Inserting this in a
PendingIntent
and sending it to theNotificationManager
Then, once I click on the notification, the service (MyService
) is started and launches a music soundtrack.
Using logging I saw that the click of the button and the actions of MyService
both happen on the main thread, and I would like to know how can I make the service run in a separate background thread
p.s. MyService
is extending Service
and not IntentService
because this last one terminates once executed