Comments (11)
成功了!感谢解答
把
activity?.dataChannel()
改成activity?.application?.dataChannel()
就能接收到宿主传来的消息了
这个限制是我手动加的,因为会考虑到当前多个 Activity
注册了广播监听的情况,这样在你发送广播的时候,可能已经打开了二级页面,但是之前的页面还是能重复收到广播,所以判断了是否为当前 Activity
,如果你没有这个需求,就可以使用 Application
注册全局广播,就不会受到 Activtity
的作用域限制。
from yukihookapi.
不用呀,你测试的 Android 版本是什么,我需要知道
from yukihookapi.
安卓13和安卓12
from yukihookapi.
在你需要接收广播的 Activity 配置中只需要添加 android:exported="true"
就可以了,你试试。
from yukihookapi.
似乎不行,能确定Activity是android:exported="true"
的。而且显示在启动器之后,也需要先从启动器打开模块后才能收到消息。如果先把模块杀后台,再从宿主内跳转到模块Activity,也收不到消息。
我在demo上复现了一下,把intent-filter注释掉了,然后在点击SEND MSG TO MODULE
时跳转模块,延迟3秒再发送消息,结果模块没收到消息。
BTW, 我的测试设备是
- 安卓12,类原生,evolution_venus-userdebug 12 SP2A.220505.002 2206020221
- 安卓13,MIUI by xiaomi.eu 14.0.31.0.TMCCNXM
from yukihookapi.
不可以的,模块和宿主必须保持存活
from yukihookapi.
你可以参考 https://github.com/fankes/MIUINativeNotifyIcon 这个项目,这个就是使用二级页面发送的消息
from yukihookapi.
你可以描述一下你的使用场景,一般情况下不建议直接做广播通信
from yukihookapi.
你可以描述一下你的使用场景,一般情况下不建议直接做广播通信
我的模块设置界面需要动态展示一些选项(屏蔽底部导航栏的tab),所以需要从宿主那边查询一些信息(导航栏有哪些tab)。所以现在我打算这样做,因为模块设置界面只能从宿主跳转来,所以我认为进入设置界面时宿主一定存活,然后设置界面会向宿主发一条消息,宿主收到消息以后把tab信息发送给设置界面,设置界面再根据信息展示选项。
不可以的,模块和宿主必须保持存活
不太确定你说的存活是否和我理解的相同,我目前的场景下宿主给模块发消息时,模块的设置界面是在前台运行的(虽然这个设置界面是宿主startActivity打开的),我理解这个状态也是“存活”
from yukihookapi.
你可以通过非 Activity
发送和接收广播,比如 getApplication()
,这样就可以绕过判断是否为当前 Activity 接收广播的限制
from yukihookapi.
成功了!感谢解答
把activity?.dataChannel()
改成activity?.application?.dataChannel()
就能接收到宿主传来的消息了
from yukihookapi.
Related Issues (20)
- [BUG] YukiHookDataChannel. Supporting Android 14 HOT 3
- 是否会支持增加Modern Xposed API HOT 1
- hello
- [BUG] HookParam call timing problem HOT 20
- New Hook Entry Class
- New Xposed Module Config Plan
- Need help, prefs doesn`t work HOT 10
- YukiHookPrefsBridge read value not working in the release mode HOT 4
- [BUG] 仅在Android 9 版本 registerModuleAppActivities 错误 HOT 9
- https://jihulab.com/xihan123/QDReadHook.git HOT 3
- Migrating to 1.2.0 HOT 1
- 增加模块的Context 获取 和 模块classload 合并入宿主 HOT 1
- cannot be cast to 类型转换异常 HOT 1
- how to change hook behavior without relaunch? HOT 1
- Classifier 'enum class HookEntryType : Enum<HookEntryType>' does not have a companion object HOT 7
- registerModuleAppActivities() 注册活动,不会初始化activity HOT 6
- 两个小建议 HOT 1
- 构建时报错找不到ksp HOT 1
- can i remove androidx? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yukihookapi.