本文整理汇总了Java中android.view.accessibility.AccessibilityNodeInfo.findAccessibilityNodeInfosByViewId方法的典型用法代码示例。如果您正苦于以下问题:Java AccessibilityNodeInfo.findAccessibilityNodeInfosByViewId方法的具体用法?Java AccessibilityNodeInfo.findAccessibilityNodeInfosByViewId怎么用?Java AccessibilityNodeInfo.findAccessibilityNodeInfosByViewId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.accessibility.AccessibilityNodeInfo
的用法示例。
在下文中一共展示了AccessibilityNodeInfo.findAccessibilityNodeInfosByViewId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findViewIdAndClick
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/**
* 检查viewId进行点击
*
* @param accessibilityService
* @param id
*/
public static void findViewIdAndClick(AccessibilityService accessibilityService, String id) {
AccessibilityNodeInfo accessibilityNodeInfo = accessibilityService.getRootInActiveWindow();
if (accessibilityNodeInfo == null) {
return;
}
List<AccessibilityNodeInfo> nodeInfoList = accessibilityNodeInfo.findAccessibilityNodeInfosByViewId(id);
if (nodeInfoList != null && !nodeInfoList.isEmpty()) {
for (AccessibilityNodeInfo nodeInfo : nodeInfoList) {
if (nodeInfo != null) {
performClick(nodeInfo);
break;
}
}
}
}
示例2: contentChange
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/**
* 内容改变
*
* @param event
*/
private void contentChange(AccessibilityEvent event) {
AccessibilityNodeInfo root = getRootInActiveWindow();
if (root == null) {
return;
}
if (WechatVersionUtils.canFindViewById(context) && WechatVersionUtils.canRobWechatVersion(context)) {
List<AccessibilityNodeInfo> exitNodeInfos = root.findAccessibilityNodeInfosByViewId(WechatVersionUtils.getWechatExitId(context));
if (exitNodeInfos != null && exitNodeInfos.size() > 0) {
// 是聊天界面
if (isWechatAlway) {
}
} else {
isWechatAlway = false;
}
}
}
示例3: getAccessibilityNodeInfo
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/***
* Find a matched node by the method, {@link AccessibilityNodeInfo#findAccessibilityNodeInfosByViewId}.
* @param accessibilityNodeInfo
* @param stringResName
* @return
*/
public static AccessibilityNodeInfo getAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo, String stringResName) {
AccessibilityNodeInfo foundNodeInfo = null;
List<AccessibilityNodeInfo> foundNodeInfos;
if (Utils.hasJellyBeanMR2()) {
foundNodeInfos = accessibilityNodeInfo.findAccessibilityNodeInfosByViewId(stringResName);
if ((foundNodeInfos != null) && (!foundNodeInfos.isEmpty())) {
foundNodeInfo = foundNodeInfos.get(0);
} else {
LogUtils.LOGD(TAG, "(getAccessibilityNodeInfo) Not found : " + stringResName);
}
while (foundNodeInfos.size() > 1) {
foundNodeInfos.remove(-1 + foundNodeInfos.size()).recycle();
}
}
return foundNodeInfo;
}
示例4: aliFuclickReplayBtn
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private void aliFuclickReplayBtn(AccessibilityEvent event) {
Log.d(TAG, "aliFuclickReplayBtn() called with: event = [" + event + "]");
Log.d(TAG, "aliFuclickReplayBtn() called with: event.getClassName() = [" + event.getClassName() + "]");
if ("android.app.Dialog".equals(event.getClassName())) {
AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();
List<AccessibilityNodeInfo> sendButtonInfo = nodeInfo.findAccessibilityNodeInfosByViewId("com.alipay.mobile.scan.arplatform:id/lucky_button");
if (!sendButtonInfo.isEmpty()) {
Toast.makeText(this, "自动帮你点击[再来一次]", Toast.LENGTH_SHORT).show();
sendButtonInfo.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
sendButtonInfo = nodeInfo.findAccessibilityNodeInfosByViewId("com.alipay.android.phone.wallet.roosteryear:id/cr_receive");
if (!sendButtonInfo.isEmpty()) {
Toast.makeText(this, "自动帮你点击[收下福卡]", Toast.LENGTH_SHORT).show();
sendButtonInfo.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
sendButtonInfo = nodeInfo.findAccessibilityNodeInfosByViewId("com.alipay.mobile.scan.arplatform:id/cover_click_button");
if (!sendButtonInfo.isEmpty()) {
Toast.makeText(this, "自动帮你点击[点击重试]", Toast.LENGTH_SHORT).show();
sendButtonInfo.get(0).performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
}
}
示例5: openEnvelopeWx
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void openEnvelopeWx() {
AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();
if (nodeInfo == null) {
Log.w(TAG, "rootWindow为空");
return;
}
List<AccessibilityNodeInfo> list6 = nodeInfo.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/b43");
Log.w(TAG, "b43list:" + list6);
for (AccessibilityNodeInfo n : list6) {
n.performAction(AccessibilityNodeInfo.ACTION_CLICK);
isAutoOpen = true;
}
/**
* 判断一下是否已经被抢完了 抢完了就返回
*/
List<AccessibilityNodeInfo> list7 = nodeInfo.findAccessibilityNodeInfosByText(WX_ACTION_BACK_NO_MONEY);
if (list7 != null && list7.size() != 0) {
Log.e(TAG, "[红包被抢完],手动返回");
performGlobalAction(GLOBAL_ACTION_HOME);
}
}
示例6: autoFetchFrData
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public void autoFetchFrData(AccessibilityEvent event, AccessibilityNodeInfo node,WeixinAutoService context,Map<String,String> record){
if(node==null){
LogUtil.d("autoFetchFrData","node 为空;");
node = context.getRootInActiveWindow();
return;
}
Set<String> set = new HashSet<String>();
//if(node.getChildCount()>0){
List<AccessibilityNodeInfo> items = new ArrayList<AccessibilityNodeInfo>();
List<AccessibilityNodeInfo> items0 = node.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/b66");
List<AccessibilityNodeInfo> items1 = node.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/mo");
if(items0==null&&items1==null){ LogUtil.d("autoFetchFrData","列表数据为空");return;}
items.addAll(items0);
items.addAll(items1);
if(items!=null&&items.size()>0){
for(AccessibilityNodeInfo item:items){
String text = item.getText().toString();
set.add(text);
if(isExist(strs,text)){
System.out.println("重复---->"+text);
}else{
LogUtil.d("autoFetchFrData",text);
}
}
}
// }
int waitTimes = 4000+(int) (Math.random()*1200);
AutoUtil.sleep(waitTimes);
AccessibilityNodeInfo nodeInfo2 = AutoUtil.findNodeInfosById(node,"com.tencent.mm:id/csl");//listView
if(nodeInfo2!=null){
nodeInfo2.performAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
}
}
示例7: iteratorJD
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private void iteratorJD(AccessibilityNodeInfo info) {
if (info.getText() != null) {
if (info.getText().toString().contains("会员") && !info.getText().equals("PLUS会员")) {
AccessibilityNodeInfo parent = info.getParent();
if ("android.widget.RelativeLayout".equals(parent.getClassName())
&& parent.isClickable()) {
parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
found = true;
return ;
}
}
if (info.getText().equals("签到")
&& info.findAccessibilityNodeInfosByViewId("com.jd.lib.coupon:id/sign_get_button") != null
&& info.isClickable()) {
info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
found = true;
return;
}
} else {
for (int i = 0; i < info.getChildCount(); i++) {
if(info.getChild(i)!=null){
if (found) {
found = false;
break;
}
iteratorJD(info.getChild(i));
}
}
}
return ;
}
示例8: fineNodeByIdAndText
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public static AccessibilityNodeInfo fineNodeByIdAndText(AccessibilityNodeInfo nodeInfo,String id,String text){
AccessibilityNodeInfo result = null;
if(nodeInfo==null) return result;
List<AccessibilityNodeInfo> nodes = nodeInfo.findAccessibilityNodeInfosByViewId(id);
if(nodes == null || nodes.isEmpty()) return result;
for(AccessibilityNodeInfo node:nodes){
String name = node.getText()+"";
if(name.equals(text)){
result = node;
break;
}
}
return result;
}
示例9: WeChatUIRobRedMoney
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private void WeChatUIRobRedMoney(AccessibilityNodeInfo nodeInfo) {
if (isSelfSendMoney) {
// 自己发的,回复一下数据
detailGetMoneyOk = false;
detailGetNameOk = false;
}
if (!isNotDO) {
S(" 准备点击红包--");
// 红包
List<AccessibilityNodeInfo> redMoneyItems = nodeInfo.findAccessibilityNodeInfosByViewId(WechatVersionUtils.getWechatGetRedMoneyId(context));
S(" redMoneyItems:" + redMoneyItems);
if (redMoneyItems != null && redMoneyItems.size() > 0) {
AccessibilityNodeInfo nodeInfo1 = redMoneyItems.get(redMoneyItems.size() - 1);
S(" 要开始点击红包了:" + nodeInfo1.getText().toString());
if (nodeInfo1.getText().toString().equals("查看红包")||nodeInfo1.getText().toString().equals("领取红包")) {
// TODO 是否抢自己的红包
boolean isRobSelf = true;
if (!isRobSelf) {
return;
}
isSelfSendMoney = true;
} else {
isSelfSendMoney = false;
}
// TODO 随机延时 固定延时
delayRob(nodeInfo1.getParent());
}
}
isNotDO = false;
}
示例10: click
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private void click(String clickId) {
AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();
if (nodeInfo != null) {
List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByViewId(clickId);
for (AccessibilityNodeInfo item : list) {
item.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
}
}
示例11: findNodeById
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
/**
* 根据id查找结点,存在返回不存在返回null
*
* @param nodeInfo
* @param viewId
* @return
*/
public static AccessibilityNodeInfo findNodeById(AccessibilityNodeInfo nodeInfo, String viewId) {
if (nodeInfo == null || viewId == null) {
return null;
}
List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByViewId(viewId);
if (list != null && list.size() > 0) {
return list.get(0);
}
return null;
}
示例12: findEditTextSend
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private boolean findEditTextSend(AccessibilityNodeInfo rootNode,String content) {
List<AccessibilityNodeInfo> editInfo = rootNode.findAccessibilityNodeInfosByViewId(Contant.chatUI_EditText_id);
if(editInfo!=null&&!editInfo.isEmpty()){
Bundle arguments = new Bundle();
arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, content);
editInfo.get(0).performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);
return true;
}
return false;
}
示例13: iteratorJDF
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
private void iteratorJDF(AccessibilityNodeInfo info) {
if (info.getText() != null) {
if (info.getText().equals("忘记手势密码")) {
gestureLockFlag = true;
return;
}
/*
if (info.getText().toString().contains("钢镚明细")) {
if (info.isClickable() && info.findAccessibilityNodeInfosByViewId("com.jd.jrapp:id/btn_feedback_summit") != null) {
info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
found = true;
return;
}
}
*/
if (info.getText().equals("签到")) {
AccessibilityNodeInfo parent = info.getParent();
if (info.findAccessibilityNodeInfosByViewId("com.jd.jrapp:id/tv_item_text") != null
&& "android.widget.RelativeLayout".equals(parent.getClassName())
&& parent.isClickable()) {
parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
found = true;
return;
}
if (info.isClickable() && info.findAccessibilityNodeInfosByViewId("com.jd.jrapp:id/btn_feedback_summit") != null) {
info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
found = true;
return;
}
}
} else {
for (int i = 0; i < info.getChildCount(); i++) {
if(info.getChild(i) != null){
if (gestureLockFlag || found) {
found = false;
break;
}
iteratorJDF(info.getChild(i));
}
}
}
return ;
}
示例14: autoLogin
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public void autoLogin(AccessibilityEvent event, AccessibilityNodeInfo nodeInfo, WeixinAutoService context, Map<String,String> record){
List<String[]> accounts = this.getAccount();
int eventType = event.getEventType();
if(nodeInfo==null){
LogUtil.d("autoFetchFrData","node 为空;");
return;
}
//1、退出当前账号
if(AutoUtil.checkAction(record,Constants.LOGIN_ACTION_08)||AutoUtil.checkAction(record,Constants.CHAT_LISTENING)){
AccessibilityNodeInfo exitCurrentAcountBtn = AutoUtil.findNodeInfosByText(nodeInfo,"退出当前帐号");
AutoUtil.performClick(exitCurrentAcountBtn,record,Constants.LOGIN_ACTION_01,500);
return;
}
//2、确认退出
if(AutoUtil.checkAction(record,Constants.LOGIN_ACTION_01)){
AccessibilityNodeInfo quiteConfirmBtn = nodeInfo.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/bu8").get(0).getChild(1);
//AccessibilityNodeInfo quiteConfirmBtn = AutoUtil.findNodeInfosById(nodeInfo,"com.tencent.mm:id/bu8");
AutoUtil.performClick(quiteConfirmBtn,record,Constants.LOGIN_ACTION_02);
return;
}
//3、更多
if(AutoUtil.checkAction(record,Constants.LOGIN_ACTION_02)){
AccessibilityNodeInfo moreBtn = AutoUtil.findNodeInfosByText(nodeInfo,"更多");
AutoUtil.performClick(moreBtn,record,Constants.LOGIN_ACTION_03,500);
return;
}
//4、切换账号
if(AutoUtil.checkAction(record,Constants.LOGIN_ACTION_03)){
List<AccessibilityNodeInfo> changeAccount = nodeInfo.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/amv");
if(changeAccount!=null&&changeAccount.size()>0){
AutoUtil.performClick(changeAccount.get(0).getChild(0),record,Constants.LOGIN_ACTION_04);
}
return;
}
//5、使用其他方式登录
if(AutoUtil.checkAction(record,Constants.LOGIN_ACTION_04)){
AccessibilityNodeInfo changeLoginWayBtn = AutoUtil.findNodeInfosByText(nodeInfo,"使用其他方式登录");
AutoUtil.performClick(changeLoginWayBtn,record,Constants.LOGIN_ACTION_05,500);
return;
}
//6、输入账号、密码、点击登录
if(AutoUtil.checkAction(record,Constants.LOGIN_ACTION_05)){
List<AccessibilityNodeInfo> userNode = nodeInfo.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/bfm");
if(userNode!=null&&userNode.size()==1){
String username = accounts.get(accountIndex)[0];
AutoUtil.performSetText(userNode.get(0).getChild(1),username,record,Constants.LOGIN_ACTION_06);
}
List<AccessibilityNodeInfo> pwdNode = nodeInfo.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/bfn");
if(pwdNode!=null&&pwdNode.size()==1){
AutoUtil.performSetText(pwdNode.get(0).getChild(1),accounts.get(accountIndex)[1],record,Constants.LOGIN_ACTION_07);
}
AutoUtil.sleep(500);
AccessibilityNodeInfo loginBtn = AutoUtil.findNodeInfosById(nodeInfo,"com.tencent.mm:id/bfo");
AutoUtil.performClick(loginBtn,record,Constants.LOGIN_ACTION_08);
if(accounts.size()-1==accountIndex){
accountIndex = 0;
}else {
accountIndex = accountIndex+1;
}
AutoUtil.recordAndLog(record,Constants.CHAT_LISTENING);
}
}
示例15: findNodeInfosById
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
public static AccessibilityNodeInfo findNodeInfosById(AccessibilityNodeInfo nodeInfo, String id) {
if(nodeInfo==null) return null;
List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByViewId(id);
if(list == null || list.isEmpty()) return null;
return list.get(0);
}