您好!欢迎来到聚码网

聚码网

热门搜索: 相亲小程序    搭子源码    直播系统自有商城   
  • 同样一句代码,为何在不同版本的Android手机上显示不同结果
  • 聚码交流
  • 0 1
  • yhuxAvNbtxUM
    0000-00-00 00:00:00
  • 回帖
我编写了一个AccessibilityService服务,用以控制微信。但在随后的过程中遇到了如下情况:有些代码在Android4.4的机器上(手机A,华为荣耀6+,Android4.4)与在Android7.0的机器上(手机B,华为P9),跑得的结果不一样,于是产生问题2个。1、在手机上手机运行AccessibilityService代码,其中有以下两行:Log.d(TAG,"获取事件-->Log.d"+event);Log.w(TAG,"获取事件-->Log.w"+event);在手机A上,LogCat能显示两条Log,而在手机B却只能显示1条Log。2、获取窗口节点时:AccessibilityNodeInfonodeInfo=getRootInActiveWindow();if(nodeInfo==null){Log.w(TAG,"rootWindow为空");return;}在手机A(华为荣耀6+,Android4.4)上,能获取到微信(com.tencent.mm)的节点信息,而在手机B(华为P9,Android7.0)却显示了系统界面(ui.laucher)的节点信息。很疑惑。全部代码如下:publicclassAcceServextendsAccessibilityService{privateStringTAG=getClass().getSimpleName();privatebooleanisFinish=false;privateintindex=1;protectedvoidonServiceConnected(){super.onServiceConnected();Log.d(TAG,"onServiceConnected!");Log.w(TAG,"onServiceConnected!");Toast.makeText(AcceServ.this,"连接服务成功。请开启AcceServ",Toast.LENGTH_LONG).show();}@OverridepublicvoidonAccessibilityEvent(AccessibilityEventevent){finalinteventType=event.getEventType();Log.d(TAG,"获取事件-->"+event);Log.w(TAG,"获取事件-->"+event);AccessibilityNodeInfonodeInfo=getRootInActiveWindow();if(nodeInfo==null){Log.w(TAG,"rootWindow为空");return;}do_some_thing();}@OverridepublicvoidonInterrupt(){}}
最近热帖
近期热议
联系我们
Q Q:317563994
电话:400-000-000
邮箱:317563994@qq.com
时间:09:00 - 17:00