gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 00:22:07 36 4
gpt4 key购买 nike

这是通过代码注册广播接收器以在另一个进程中运行的方法吗?就像我在带有 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/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com