android - 从代码注册广播接收器以在远程进程中运行

标签 android broadcastreceiver

这是通过代码注册广播接收器以在另一个进程中运行的方法吗?就像我在带有 android:process=":remote"属性的 list 文件中设置它一样。

Intent registerReceiver (BroadcastReceiver receiver, IntentFilter filter)

Register a BroadcastReceiver to be run in the main activity thread. The receiver will be called with any broadcast Intent that matches filter, in the main application thread.

android:process

... If the name assigned to this attribute begins with a colon (':'), a new process, private to the application, is created when it's needed and the broadcast receiver runs in that process.

最佳答案

Is that a way for register broadcast receiver to running in another process from the code?

registerReceiver(),在 Context 上调用,适用于来自其他进程的广播。

但是,当接收到广播时,registerReceiver() 不会创建另一个进程,而 android:process 就是这样做的。 android:process发送广播的进程无关。

关于android - 从代码注册广播接收器以在远程进程中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46082289/

相关文章:

java - 在 Android 应用程序中显示叠加帮助

Android TextView 特殊字符问题

android - 服务和 BroadCastReceiver

java - 当按下 MainActivity 中的按钮时实现 onReceive()

android - 支持库中的 WakefulBroadcastReceiver 与 commonsware 的 cwac-wakeful

android - 如何获取同一BTS下的设备Cell ID?

java - 通话/连接到 Android 上的安全元素小程序 micro sd?

Android M 权限安装/更新行为

android - 为什么我们可以通过BroadcastReceiver 与BLE 设备配对,而不显示系统Dialog?

java - 警报管理器有时会在错误的时间触发