Android BroadcastReceiver: run it by default or in a new one?

I have an application with two broadcast receivers, one for receiving data and the other for sending. I saw that they have the android: process attribute in order to get them to work in the default application process or in another. In the examples I found using Google, receivers were configured to run in the ": remote" process.

My question is, what are the advantages and disadvantages of using each option?

+4
source share
2 answers

Using a different process than the default application process is convenient if you want to share resources with another application.

Todo, so you need to organize two Applications with the same process name, if your process name starts at the bottom, a global process is created. If it starts with a colon: the process is private. Keep in mind that sharing the process between two applications requires the same user ID and the same application certificate.

You should also load resources only once and take advantage of memory consumption.

for additional information

+2
source

The process has its own main thread. Thus, when using different processes, i.e. :remote , this means that the code defined in this process will work in a separate thread. Usually you do not need to do this for a normal workflow.

0
source

Source: https://habr.com/ru/post/1439755/


All Articles