`
hyshucom
  • 浏览: 808424 次
文章分类
社区版块
存档分类
最新评论

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"


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics