當前位置: 首頁>>代碼示例>>Java>>正文


Java AccessibilityNodeInfo.findAccessibilityNodeInfosByText方法代碼示例

本文整理匯總了Java中android.view.accessibility.AccessibilityNodeInfo.findAccessibilityNodeInfosByText方法的典型用法代碼示例。如果您正苦於以下問題:Java AccessibilityNodeInfo.findAccessibilityNodeInfosByText方法的具體用法?Java AccessibilityNodeInfo.findAccessibilityNodeInfosByText怎麽用?Java AccessibilityNodeInfo.findAccessibilityNodeInfosByText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.accessibility.AccessibilityNodeInfo的用法示例。


在下文中一共展示了AccessibilityNodeInfo.findAccessibilityNodeInfosByText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: hasAccessibilityNode

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
public static boolean hasAccessibilityNode(AccessibilityNodeInfo info, String[] texts) {
    if (texts != null) {
        for (String textItem : texts) {
            List<AccessibilityNodeInfo> nodes = info.findAccessibilityNodeInfosByText(textItem);
            if (nodes != null && !nodes.isEmpty()) {
                AccessibilityNodeInfo node;
                for (int i = 0; i < nodes.size(); i++) {
                    node = nodes.get(i);
                    BaseAccessibility.logPrint("find text=" + textItem + "  enable=" + node.isEnabled());
                    CharSequence text = node.getText();
                    if (TextUtils.equals(text, textItem)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
開發者ID:miLLlulei,項目名稱:Accessibility,代碼行數:20,代碼來源:BaseAccessibility.java

示例2: getAllHongBao

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
private void getAllHongBao(AccessibilityNodeInfo info){
	runState=true;
	Log.i(TAG,"獲取所有紅包");
	time=System.currentTimeMillis();
	List<AccessibilityNodeInfo> list=new ArrayList<AccessibilityNodeInfo>();
	//查找出當前頁麵所有的紅包,包括手氣紅包和口令紅包
	for(String word:QQ_KEYWORD_HONGBAO){
		List<AccessibilityNodeInfo> infolist  = info.findAccessibilityNodeInfosByText(word);
		if(!infolist.isEmpty()){
			for(AccessibilityNodeInfo node:infolist){
				//這裏進行過濾可點擊的紅包,放到後麵去過濾的話感覺非常操蛋
				if(node.getText()==null||
				    //過濾出包含關鍵字的節點,隻取和關鍵字相同的
				    !node.getText().toString().equals(word)||
					/**
					 * 下麵這個條件是過濾已拆開的紅包
					 * 如果口令紅包的口令設置成"口令紅包"
					 * 會讓插件陷入死循環,所以必須加個新的判斷條件
					 * 不過這樣會耗費更多的時間,所以口令盡量不要設置成關鍵字
					 */
					node.getParent().getChildCount()!=3||
				   !node.getParent().findAccessibilityNodeInfosByText(CAIKAI).isEmpty()||
				   !node.getParent().findAccessibilityNodeInfosByText(CHAKANXIANGQING).isEmpty())
				continue;
				list.add(node);
			}
		}
	}
	if(list.size()==0) {
		runState=false;
		return ;
	}
	Toast.makeText(this,"連續搶到紅包數量:"+list.size(),1000).show();
	clickAction(list);
}
 
開發者ID:qq1198,項目名稱:mtoolbox,代碼行數:36,代碼來源:HongBaoService.java

示例3: getFromNode

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
/**
    * 搜索包含紅包的UI節點, 點擊所有
    *
    * @param root 根UI節點
    * @return 成功點擊的紅包數
    */
   Integer getFromNode(AccessibilityNodeInfo root)
   {
List<AccessibilityNodeInfo> mNodes =
    root.findAccessibilityNodeInfosByText(getResources().getString(R.string.chat_pattern));

for (AccessibilityNodeInfo node : mNodes)
{
    // Log.d("node", node.toString());
    AccessibilityNodeInfo parent = node.getParent();
    if (parent == null)
    {
	//Log.d("node.parent", "null"); // 有時候沒有父節點, 蜜汁bug
    }
    else
    {
	//Log.d("click", "GET" + Integer.valueOf(node.hashCode()).toString());
	parent.performAction(AccessibilityNodeInfo.ACTION_CLICK); // TextView不能點, 點的是ListView, 詳情查看clickable
	cnt_get += 1;
	lastNode = node.hashCode();
    }
}

return mNodes.size(); // 即搜索結果數目
   }
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:31,代碼來源:AnimatedEditText.java

示例4: containAccessibilityNode

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
public static boolean containAccessibilityNode(AccessibilityNodeInfo info, String[] texts) {
    if (texts != null) {
        for (String textItem : texts) {
            List<AccessibilityNodeInfo> nodes = info.findAccessibilityNodeInfosByText(textItem);
            if (nodes != null && !nodes.isEmpty()) {
                AccessibilityNodeInfo node;
                for (int i = 0; i < nodes.size(); i++) {
                    node = nodes.get(i);
                    BaseAccessibility.logPrint("find text=" + textItem + "  enable=" + node.isEnabled());
                    CharSequence text = node.getText();
                    if (!TextUtils.isEmpty(text)) {
                        if (text.toString().contains(textItem)) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
開發者ID:miLLlulei,項目名稱:Accessibility,代碼行數:22,代碼來源:BaseAccessibility.java

示例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);
    }
}
 
開發者ID:mcxtzhang,項目名稱:miser-utils,代碼行數:23,代碼來源:ComeOnMoneyService.java

示例6: findGiftInChat

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
private void findGiftInChat() {
    AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();
    if (nodeInfo == null) {
        Log.w(TAG, "rootWindow為空");
        return;
    }
    List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText(DINGDING_ACTION_SEE_GIFT);
    if (list != null) {
        for (AccessibilityNodeInfo n : list) {
            //點擊父控件 ListView的Item
            AccessibilityNodeInfo parent = n.getParent();
            Log.i(TAG, "-->聊天界麵尋找釘釘紅包:" + n);
            parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
            break;
        }
    }
}
 
開發者ID:mcxtzhang,項目名稱:miser-utils,代碼行數:18,代碼來源:ComeOnMoneyService.java

示例7: enterChatHasGift

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
private void enterChatHasGift() {
    AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();
    if (nodeInfo == null) {
        Log.w(TAG, "rootWindow為空");
        return;
    }
    List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText(DINGDING_ENVELOPE_TEXT_KEY);
    if (list != null) {
        for (AccessibilityNodeInfo n : list) {
            //點擊父控件 ListView的Item
            AccessibilityNodeInfo parent = n.getParent();
            Log.i(TAG, "-->主界麵尋找釘釘紅包:" + n);
            parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
            break;
        }
    }
}
 
開發者ID:mcxtzhang,項目名稱:miser-utils,代碼行數:18,代碼來源:ComeOnMoneyService.java

示例8: openNext2

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
private void openNext2(String str, AccessibilityNodeInfo nodeInfo, final AccessibilityService service) {
    if (nodeInfo == null) {
        L.d("rootWindow為空");
        return;
    } else {
        L.d("openNext2 " + nodeInfo.getText());
    }
    List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText(str);
    if (list.isEmpty()) {
        return;
    } else {
        CharSequence text = list.get(list.size() - 1).getText();
        if (TextUtils.isEmpty(text)) {
            return;
        } else {
            L.d("openNext2 " + text);
        }
    }

    i++;
    if (isGo) {
        isGo = false;
    }
}
 
開發者ID:kaixuanluo,項目名稱:pc-android-controller-android,代碼行數:25,代碼來源:WeChatNearly.java

示例9: findDialogAndClick

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
/**
 * 在當前頁麵查找對話框文字內容並點擊
 *
 * @param text1 默認點擊text1
 * @param text2
 */
public static void findDialogAndClick(AccessibilityService accessibilityService, String text1, String text2) {

    AccessibilityNodeInfo accessibilityNodeInfo = accessibilityService.getRootInActiveWindow();
    if (accessibilityNodeInfo == null) {
        return;
    }

    List<AccessibilityNodeInfo> dialogWait = accessibilityNodeInfo.findAccessibilityNodeInfosByText(text1);
    List<AccessibilityNodeInfo> dialogConfirm = accessibilityNodeInfo.findAccessibilityNodeInfosByText(text2);
    if (!dialogWait.isEmpty() && !dialogConfirm.isEmpty()) {
        for (AccessibilityNodeInfo nodeInfo : dialogWait) {
            if (nodeInfo != null && text1.equals(nodeInfo.getText())) {
                performClick(nodeInfo);
                break;
            }
        }
    }

}
 
開發者ID:xmlxin,項目名稱:ReplyMessage,代碼行數:26,代碼來源:PerformClickUtils.java

示例10: findTextAndClick

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
/**
 * 在當前頁麵查找文字內容並點擊
 *
 * @param text
 */
public static void findTextAndClick(AccessibilityService accessibilityService, String text) {

    AccessibilityNodeInfo accessibilityNodeInfo = accessibilityService.getRootInActiveWindow();
    if (accessibilityNodeInfo == null) {
        return;
    }

    List<AccessibilityNodeInfo> nodeInfoList = accessibilityNodeInfo.findAccessibilityNodeInfosByText(text);
    if (nodeInfoList != null && !nodeInfoList.isEmpty()) {
        for (AccessibilityNodeInfo nodeInfo : nodeInfoList) {
            if (nodeInfo != null && (text.equals(nodeInfo.getText()) || text.equals(nodeInfo.getContentDescription()))) {
                performClick(nodeInfo);
                break;
            }
        }
    }
}
 
開發者ID:xmlxin,項目名稱:ReplyMessage,代碼行數:23,代碼來源:PerformClickUtils.java

示例11: getFromLastNode

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
/**
    * 搜索包含紅包的UI節點, 點擊末幾個
    *
    * @param root      根UI節點
    * @param size      點擊最後size個
    * @param ignoreDup 是否無視重複檢測
    * @return 成功點擊的紅包數
    */
   Integer getFromLastNode(AccessibilityNodeInfo root, Integer size, boolean ignoreDup)
   {
List<AccessibilityNodeInfo> mNodes =
    root.findAccessibilityNodeInfosByText(getResources().getString(R.string.chat_pattern));

size = Math.min(size, mNodes.size()); // 先設成功點擊數為預計點擊的紅包數目
for (Integer i = mNodes.size() - size; i < mNodes.size(); i++)
{
    AccessibilityNodeInfo node = mNodes.get(i);
    //  Log.d("node", node.toString());
    AccessibilityNodeInfo parent = node.getParent();
    if (parent == null)
    {
	//Log.d("node.parent", "null"); // 有時候沒有父節點, 蜜汁bug
    }
    else
    {
	if (ignoreDup || (lastNode != node.hashCode()))
	{ // 非重複紅包, 點擊
	    //    Log.d("click", "GET" + Integer.valueOf(node.hashCode()).toString());
	    parent.performAction(AccessibilityNodeInfo.ACTION_CLICK);
	    cnt_get += 1;
	    lastNode = node.hashCode();
	}
	else
	{
	    //   Log.d("node duplicate", Integer.valueOf(node.hashCode()).toString());
	    size -= 1; // 重複紅包, 減少成功計數
	}
    }
}

return size;
   }
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:43,代碼來源:AnimatedEditText.java

示例12: QQpackge

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
private void QQpackge(AccessibilityEvent event) {
    if ("com.tencent.mobileqq.activity.VisitorsActivity".equals(event.getClassName().toString())) {
        AccessibilityNodeInfo root = getRootInActiveWindow();
        if (root != null) {
            List<AccessibilityNodeInfo> nodes = root.findAccessibilityNodeInfosByText("讚");
            for (int i = 0; i < nodes.size(); i++) {
                for (int j = 0; j < 10; j++) {
                    nodes.get(i).performAction(AccessibilityNodeInfo.ACTION_CLICK);
                }
            }
        }
    }
}
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:14,代碼來源:SeText.java

示例13: getAllHongBao

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
private void getAllHongBao(AccessibilityNodeInfo info)
   {
runState = true;
//Log.i(TAG, "獲取所有紅包");
time = System.currentTimeMillis();
List<AccessibilityNodeInfo> list=new ArrayList<AccessibilityNodeInfo>();
//查找出當前頁麵所有的紅包,包括手氣紅包和口令紅包
for (String word:QQ_KEYWORD_HONGBAO)
{
    List<AccessibilityNodeInfo> infolist  = info.findAccessibilityNodeInfosByText(word);
    if (!infolist.isEmpty())
    {
	for (AccessibilityNodeInfo node:infolist)
	{
	    //這裏進行過濾可點擊的紅包,放到後麵去過濾的話感覺非常操蛋
	    if (node.getText() == null ||!node.getText().toString().equals(word) ||node.getParent().getChildCount() != 3 ||!node.getParent().findAccessibilityNodeInfosByText(QQ_KEYWORD_FAILD_CLICK).isEmpty())
		continue;
	    list.add(node);
	}
    }
}
if (list.size() == 0)
{
    runState = false;
    return ;
}
ToastUtil.show(this,list.size()+"/"+(System.currentTimeMillis() - time) + "", Toast.LENGTH_SHORT);
//Log.i(TAG, "數量>>>" + list.size() + "  獲取紅包耗時:" + (System.currentTimeMillis() - time) + "ms");
clickAction(list);
   }
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:31,代碼來源:dex_smali.java

示例14: findAndAccessAccessibilityNode

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
public static boolean findAndAccessAccessibilityNode(AccessibilityNodeInfo info, String[] texts, boolean fuzzy) {
    if (texts != null) {
        for (String textItem : texts) {
            List<AccessibilityNodeInfo> nodes = info.findAccessibilityNodeInfosByText(textItem);
            if (nodes != null && !nodes.isEmpty()) {
                AccessibilityNodeInfo node;
                for (int i = 0; i < nodes.size(); i++) {
                    node = nodes.get(i);
                    BaseAccessibility.logPrint("find text=" + textItem + "  enable=" + node.isEnabled());
                    CharSequence text = node.getText();

                    if (!TextUtils.isEmpty(text)) {
                        if (textItem.equals(text.toString()) || (fuzzy && text.toString().contains(textItem))) {
                            if (node.isEnabled() && node.isClickable()) {
                                if (node.getClassName().equals("android.widget.Button")
                                        || node.getClassName().equals("android.widget.TextView")
                                        || node.getClassName().equals("android.widget.CheckBox")) {
                                    autoClickNumber++;
                                    return node.performAction(AccessibilityNodeInfo.ACTION_CLICK);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
開發者ID:miLLlulei,項目名稱:Accessibility,代碼行數:30,代碼來源:BaseAccessibility.java

示例15: findNodeByText

import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
/**
 * 通過文本查找節點(注: text是包含contains,而不是完全equals)
 * @param nodeInfo
 * @param text
 * @return
 */
public static AccessibilityNodeInfo findNodeByText(AccessibilityNodeInfo nodeInfo, String text) {
    List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText(text);
    if(list == null || list.isEmpty()) {
        return null;
    }
    return list.get(0);
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:14,代碼來源:AceHelper.java


注:本文中的android.view.accessibility.AccessibilityNodeInfo.findAccessibilityNodeInfosByText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。