android-wechat-tool
android-wechat-tool copied to clipboard
红包页面getRootInActiveWindow为null
请教下,如题,有什么解决的方案吗
private void getLuckMoney(AccessibilityNodeInfo rootEvent) throws InterruptedException {
Log.e("test", "收到红包界面----->3");
AccessibilityNodeInfo rowNode = getRootInActiveWindow();
if (rowNode == null) {
Log.e("test", "noteInfo is null");
Thread.sleep(delayTime);
performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
return ;
}
Log.e("test", "收到红包界面----->4");
List<AccessibilityNodeInfo> openList = rowNode.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/c2i");
rowNode.recycle();
for (AccessibilityNodeInfo item : openList) {
Log.e("test",item.getClassName().toString());
//item.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
xml的配置如下: <accessibility-service xmlns:android="http://schemas.android.com/apk/res/android" android:accessibilityEventTypes="typeNotificationStateChanged|typeWindowStateChanged|typeWindowContentChanged|typeWindowsChanged" android:accessibilityFeedbackType="feedbackGeneric" android:accessibilityFlags="flagDefault" android:canRetrieveWindowContent="true" android:description="@string/app_name" android:notificationTimeout="100" android:packageNames="com.tencent.mm" />
捕获不到button,点击home键,再次进入微信就能捕获到?这是为何?
我也发现这个问题了,Android 6.0之前版本的手机没问题。在Android 7.0 和 Android 8.1上测试时发现,没当窗口发生改变时getRootInActiveWindow就变成了null,百度+谷歌了半天也没查到解决办法。
@sinawangnan7 I have the same problem.In the Activity of "com.tencent.mm.plugin.luckymoney.ui.LuckyMoneyReceiveUI" ,the method of "getRootInActiveWindow()" return null.
一直试都是获取为空,使用getWindows()方法也是为空,真是无解。
如果大家还感兴趣,最近用kotlin尝试写了下只支持微信7.0版本的红包插件。后续会继续优化。 https://github.com/YummyLau/KotlinLearn/tree/master/wxrp @YahengWang @sinawangnan7 @NB-Dragon @ymxh
@YummyLau It's OK. I have found an other way to solve it, which you can see the application in NB-Dragon/RedPacketPolice. There is no source code there.
@NB-Dragon thx!Did it adpter to wechat7.0 ?
@YummyLau Not yet, but it's easy to adapt it if i want.
如果大家还感兴趣,最近用kotlin尝试写了下只支持微信7.0版本的红包插件。后续会继续优化。 https://github.com/YummyLau/KotlinLearn/tree/master/wxrp @YahengWang @sinawangnan7 @NB-Dragon @ymxh
找不到啦
@YummyLau Not yet, but it's easy to adapt it if i want.
code?
@YummyLau Not yet, but it's easy to adapt it if i want.
code?
I won't give you the code, but i will offer you a tip "dispatchGesture".
@jp https://github.com/YummyLau/WechatTools 项目被我迁移到这里了。