Search code examples
androidandroid-service

How services can be created in a separate process and can give it to other application in Android?


I know that services run in background and does not have any visual user Interface. It is used to perform long running tasks. For example, a music player contains lists of tracks so that we can play them and can work on some other application (interacting with other applications).

When the first track ends, then automatically the second track would be played. Here, we do not need to go and select for second music to be played. Music player takes care of this. Here, services help to perform this operations by running in a background.

Also, I know that if application is closed completely then services will be get destroyed but if we used to switch from one activity to another then services would be keep on running in background.

My doubt is, how services can be created in a separate process and can give it to other application in Android?

I found this link - what does it mean and how can it be done practically?


Solution

  • By default activity,service,receiver all run on the same process under same Application tag. and process name is same to your application package name;

    If you want separate process then you can name the process to other process like.

    <service android:name=".MyService"
    android:process="com.android.example.otherprocess">
    </Service>