accessibilityservice 自动安装 取消删除安装包(二)
来源:互联网 发布:微博关键词优化 编辑:程序博客网 时间:2024/05/17 03:41
<span style="font-family: Arial, Helvetica, sans-serif;"></span>
这个方法也尝试过了,完全可以
// 响应AccessibilityEvent的事件,在用户操作的过程中,系统不断的发送@Overridepublic void onAccessibilityEvent(AccessibilityEvent event) {Log.i(TAG, "onAccessibilityEvent:" + event.toString());// 1.方法可行// checkInstall(event);// 2.方法可行int eventType = event.getEventType();AccessibilityNodeInfo accessibilityNodeInfo = event.getSource();// 得到被点击的对象getRootInActiveWindow(); // 获得整个窗口对象if (eventType == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED|| eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {// 当当前窗口发生变化时候,重新遍历,否则后面的控件找不到AccessibilityNodeInfo rootInActiveWindow = getRootInActiveWindow();if (rootInActiveWindow == null) {Log.d(TAG, "the rootInActiveWindow is null");} else {recycle(rootInActiveWindow);}}// 3.方法可行// if (event.getSource() == null) {// Log.d("test", "the source = null");// } else {// Log.d("test", "event = " + event.toString());// switch (INVOKE_TYPE) {// case TYPE_KILL_APP:// // processKillApplication(event);// break;// case TYPE_INSTALL_APP:// processinstallApplication(event);// break;// case TYPE_UNINSTALL_APP:// // processUninstallApplication(event);// break;// default:// break;// }// }}
@SuppressLint("NewApi")public void recycle(AccessibilityNodeInfo rootInActiveWindow) {if (rootInActiveWindow.getChildCount() == 0) { // 只有一个子元素Log.d(TAG, "the rootInActiveWindow count is : 0");} else {for (int i = 0; i < rootInActiveWindow.getChildCount(); i++) {AccessibilityNodeInfo nodeInfo = rootInActiveWindow.getChild(i);// 这里根据UIAutomator来判断,我们当前需要点击的是buttonif (nodeInfo.getClassName().equals("android.widget.Button")) {String content = nodeInfo.getText().toString();List<AccessibilityNodeInfo> okList = nodeInfo.findAccessibilityNodeInfosByViewId("com.android.packageinstaller:id/ok_button");List<AccessibilityNodeInfo> openList = nodeInfo.findAccessibilityNodeInfosByViewId("com.android.packageinstaller:id/launch_button");if ((null != okList && okList.size() > 0)) {Log.d(TAG, "the node content is :" + content + "==the okbutton is :" + okList.get(0));// 通过performAction来实现模拟点击事件okList.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);}// 安装完成之后点击open按钮,打开当前应用if (null != openList && openList.size() > 0) {Log.d(TAG, "the node content is :" + content + "==the openButton is :" + openList.get(0));openList.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);}String cancelDelete = nodeInfo.getText().toString();// 这里的取消是我的荣耀手机上的是否删除软件安装包的,这里选择取消if ("取消".equals(cancelDelete)) {nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);}}}}}
demo下载:下载
1 0
- accessibilityservice 自动安装 取消删除安装包(二)
- accessibilityservice 自动安装 取消删除安装包
- android 使用AccessibilityService 自动安装应用
- android 使用AccessibilityService 自动安装应用
- 基于AccessibilityService实现apk自动安装
- 使用AccessibilityService进行APK自动安装
- 自动抢红包,自动安装原理之AccessibilityService
- 自动抢红包,自动安装原理之AccessibilityService
- 自动抢红包,自动安装原理之AccessibilityService
- 自动抢红包,自动安装原理之AccessibilityService
- 自动抢红包,自动安装原理之AccessibilityService
- 使用AccessibilityService实现APP的自动安装与卸载
- 取消Wmvare自动安装centOS
- AccessibilityService 智能安装,升级应用
- Jruby自动安装包
- 使用AccessibilityService带你自动安装软件以及自动添加微信好友
- 使用AccessibilityService带你自动安装软件以及自动添加微信好友
- Vmware下取消自动安装Linux系统
- Java设计模式之--迭代器模式(Iterator)
- iOS TableView实现QQ好友列表
- 南阳宾馆管理系统
- 树:伸展树
- 深入浅出RxJava(一:基础篇)
- accessibilityservice 自动安装 取消删除安装包(二)
- eclipse内存溢出问题解决方案
- java 打印日志的几种方式
- Abstract&Interface 抽象类与接口
- IE浏览器下new Date('2016-06-23 12:12:12')初始化返回NaN
- oracle透明网关通过dblink连接slq server和mysql
- 在HANA里设置后台Job
- Errors occurred during the build. Errors running builder 'Integrated Externa......
- JDBC学习笔记——增删改查