zoukankan      html  css  js  c++  java
  • android AccessibltyService 辅助服务

    1、使用Accessibility可以模拟手机点击,获取屏幕文字,通知消息等。

    2、使用该类需新建一个AccessibilityService的子类,并在AndroidManifest.xml文件中注册,并声明权限。

    在新建的子类中,重载几个重要的方法 onServiceConnected(),onAccessibilityEvent(),onInterrupt(),onUnbind()等方法。

    3、配置工作。可在onServiceConnected()中进行,可以建立一个AccessibilityServiceInfo类的对象,设置要监听的系统事件类型、监听的包名等。

    在android4以后,可以直接在res/xml/某某.xml写配置属性。  android:resource = "@xml/某某"。

    //模拟系统返回键

    AccessibilityService.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);

    //找到某View然后模拟点击

     AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();

    List<AccessibilityNodeInfo> listEt = nodeInfo.findAccessibilityNodeInfosByViewId("com.ycii.mms.ui:id/txt_home_banli");

    if(listEt.size()>0)
    listEt.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);

  • 相关阅读:
    洛谷P1182 数列分段`Section II`
    洛谷P3902 递增
    洛谷P1678-烦恼的高考志愿
    POJ 3263-Tallest Cow
    洛谷P2280 [HNOI2003]激光炸弹
    POJ 1958
    Vijos 1197
    VirtualBox 导入.vdi文件时报“uuid is exists”错误
    解压常用
    cut 命令
  • 原文地址:https://www.cnblogs.com/lzh-Linux/p/4703161.html
Copyright © 2011-2022 走看看