Should I use android: process =“:remote” in my reciver?

By defining your receiver withandroid:process=":remote" you basically run your receiver in adifferent process (= VM). For typical use-cases, you don't need to runthis in a different process, and whatever you want to do can probablyrun just fine locally (in your APK process).

The drawbacks of using android:process=":remote" is that you needadditional resources for it to run (in this case a seperate process).When doing so, you're basically dealing with 2 VMs, and some patternslike singletons, static fields can no longer be shared between your appand your remote service.

The benefits of using android:process=":remote" is that for someuse-cases, it might be handy to start a service that will keep onrunning (in its own process) after you've shutdown your application, orif you want remote clients to be able to bind to your service. Yourbroadcast receiver will not block your applications main thread whenrunning in a seperate process upon calling the onReceive method(however, there are other ways of implementing this.

I've found that most of the time, for most common use-cases, you can get away without using android:process="remote"


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值