Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
337 views
in Technique[技术] by (71.8m points)

android - Can you start an IntentService on a separate process?

  1. Is it possible to start an IntentService on a separate process? How? If so, is it mandatory to bind to it?
  2. Is it possible to start an IntentService on a separate process AND run it in the foreground?
  3. What's the difference between android:isolatedProcess and android:process? See: http://developer.android.com/guide/topics/manifest/service-element.html
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

1) Is it possible to start an IntentService on a separate process? How? If so, is it mandatory to bind to it?

Yes, you can start an IntentService in a separate process. Simply add android:process=":whatever" to the manifest entry for that service.

No, you don't need to bind to it. You can communicate with it by sending it Intents using startService()

2) Is it possible to start an IntentService on a separate process AND run it in the foreground?

Yes (see above). To make your service run in the foreground it can call startForeground() whenever it wants to do that. The service itself is in control of whether it runs in the foreground or background.

3) What's the difference between android:isolatedProcess and android:process? See: http://developer.android.com/guide/topics/manifest/service-element.html

android:process allows you to control in which process each particular component runs (by specifying the name of the process). You can group components of your application to run in separate processes (for example, all UI components in one process and all services in another). The default behaviour is that all components of an application run in the same process.

android:isolatedProcess is a flag (true/false) that you can set if you want a particular service component to run in a separate process isolated from the rest of your application. The isolated process doesn't have any of the permissions that are granted to the rest of your application. Normally, permissions are granted to an application and all components of the application have all the permissions that the application gets. android:isolatedProcess is only available starting with API level 16 (Jellybean). See http://aleksmaus.blogspot.de/2012/09/a-feature-of-android-jelly-bean.html and Advantage of introducing Isolatedprocess tag within Services in JellyBean[Android]


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...