本文整理匯總了Java中android.view.accessibility.AccessibilityNodeInfo.performAction方法的典型用法代碼示例。如果您正苦於以下問題:Java AccessibilityNodeInfo.performAction方法的具體用法?Java AccessibilityNodeInfo.performAction怎麽用?Java AccessibilityNodeInfo.performAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.accessibility.AccessibilityNodeInfo
的用法示例。
在下文中一共展示了AccessibilityNodeInfo.performAction方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendMsg
import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
public void sendMsg(AccessibilityNodeInfo node,WeixinAutoService context,Map<String,String> record){
AccessibilityNodeInfo editText = AutoUtil.findNodeInfosById(context.getRootInActiveWindow(),"com.tencent.mm:id/a3b");
//6、填充第3步已獲取消息到輸入框
if(editText!=null){
editText.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT,AutoUtil.createBuddleText(System.currentTimeMillis()+""));
AutoUtil.recordAndLog(record,Constants.CHAT_ACTION_05);
}
//7、發送
if(Constants.CHAT_ACTION_05.equals(record.get("recordAction"))){
AccessibilityNodeInfo sendBtn = AutoUtil.findNodeInfosByText(context.getRootInActiveWindow(),"發送");
AutoUtil.performClick(sendBtn,record,Constants.CHAT_ACTION_06,3000);
}
AccessibilityNodeInfo backBtn = AutoUtil.findNodeInfosById(context.getRootInActiveWindow(),"com.tencent.mm:id/gg");
AutoUtil.performClick(backBtn,record,"backBtnbackBtn",3000);
LogUtil.d("chat","69");
}
示例2: sendComment
import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
private void sendComment() {
try {
AccessibilityNodeInfo outNode =
getRootInActiveWindow().getChild(0).getChild(0);
AccessibilityNodeInfo nodeToInput = outNode.getChild(outNode.getChildCount() - 1).getChild(0).getChild(1);
if ("android.widget.EditText".equals(nodeToInput.getClassName())) {
Bundle arguments = new Bundle();
arguments.putCharSequence(AccessibilityNodeInfo
.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, signature.commentString);
nodeToInput.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);
}
} catch (Exception e) {
// Not supported
}
}
示例3: watchList
import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
private boolean watchList(AccessibilityEvent event) {
if (mListMutex) return false;
mListMutex = true;
AccessibilityNodeInfo eventSource = event.getSource();
// Not a message
if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED || eventSource == null)
return false;
List<AccessibilityNodeInfo> nodes = eventSource.findAccessibilityNodeInfosByText(WECHAT_NOTIFICATION_TIP);
//增加條件判斷currentActivityName.contains(WECHAT_LUCKMONEY_GENERAL_ACTIVITY)
//避免當訂閱號中出現標題為“[微信紅包]拜年紅包”(其實並非紅包)的信息時誤判
if (!nodes.isEmpty() && currentActivityName.contains(WECHAT_LUCKMONEY_GENERAL_ACTIVITY)) {
AccessibilityNodeInfo nodeToClick = nodes.get(0);
if (nodeToClick == null) return false;
CharSequence contentDescription = nodeToClick.getContentDescription();
if (contentDescription != null && !signature.getContentDescription().equals(contentDescription)) {
nodeToClick.performAction(AccessibilityNodeInfo.ACTION_CLICK);
signature.setContentDescription(contentDescription.toString());
return true;
}
}
return false;
}
示例4: clickAction
import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
private void clickAction(List<AccessibilityNodeInfo> infolist){
for(AccessibilityNodeInfo node :infolist){
String text=node.getText().toString();
AccessibilityNodeInfo info=getClickableNode(node);
if(info==null) continue;
info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
if(text.equals(QQ_KEYWORD_HONGBAO[1])){
onClick();
}else{
isNeedBack=true;
}
}
runState=false;
Log.i(TAG,"總共耗時:"+(System.currentTimeMillis()-time)+"ms");
}
示例5: 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(); // 即搜索結果數目
}
示例6: crawlButton
import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
/**
* 爬遍所有節點查找可點的按鈕,用於解決Android5.1等組件層次分離的情況
* @param root 界麵根節點
*/
void crawlButton(AccessibilityNodeInfo root)
{
AccessibilityNodeInfo child;
Integer size = root.getChildCount();
for (Integer i=0;i < size;i++)
{
child = root.getChild(i);
if (child != null)
{
if (child.getClassName().toString().equals("android.widget.Button"))
{
// Log.d("crawl-button", child.toString());
//Log.d("click", "OPEN");
child.performAction(AccessibilityNodeInfo.ACTION_CLICK); // 拆紅包
cnt_open += 1;
flags_detail = 1; // 紅包有效
state = State.DETAIL;
}
crawlButton(child);
}
}
}
示例7: checkKey1
import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void checkKey1()
{
AccessibilityNodeInfo nodeInfo = getRootInActiveWindow();
if (nodeInfo == null)
return;
List<AccessibilityNodeInfo> list = nodeInfo.findAccessibilityNodeInfosByText("拆紅包");
if (list == null || list.size() == 0)
{
list = nodeInfo.findAccessibilityNodeInfosByViewId("com.tencent.mm:id/b2c");
}
for (AccessibilityNodeInfo n : list)
{
n.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
}
示例8: 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;
}
}
}
示例9: performClick
import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
/**
* 點擊事件
*/
public static void performClick(AccessibilityNodeInfo nodeInfo) {
if (nodeInfo == null) {
return;
}
if (nodeInfo.isClickable()) {
nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
} else {
performClick(nodeInfo.getParent());
}
}
示例10: 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 ;
}
示例11: handleAppDetail
import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
private void handleAppDetail(AccessibilityNodeInfo source) {
AccessibilityNodeInfo forceStopNodeInfo = null;
forceStopNodeInfo = AppDetailsAutomatorUtil.getAccessibilityNodeInfo(source, FORCE_STOP_STRING_RES_NAME);
if (forceStopNodeInfo == null) {
if (Utils.hasLollipop()) {
forceStopNodeInfo = AppDetailsAutomatorUtil.getAccessibilityNodeInfo(source, FORCE_STOP_STRING_RIGHT_BOTTON);
} else {
forceStopNodeInfo = AppDetailsAutomatorUtil.getAccessibilityNodeInfo(source, FORCE_STOP_STRING_LEFT_BOTTON);
}
}
if (forceStopNodeInfo == null) {
forceStopNodeInfo = AppDetailsAutomatorUtil.findAccessibilityNodeInfo(source, mForceStop);
}
if (forceStopNodeInfo == null) {
forceStopNodeInfo = AppDetailsAutomatorUtil.findAccessibilityNodeInfo(source, mFinishApplication);
}
boolean performClick = false;
if (forceStopNodeInfo != null) {
AppDetailsAutomatorUtil.checkVisibleToUserTimeOut(forceStopNodeInfo);
if (AppDetailsAutomatorUtil.isVisibleToUser(forceStopNodeInfo)) {
AppDetailsAutomatorUtil.performClickAction(forceStopNodeInfo);
performClick = true;
}
forceStopNodeInfo.recycle();
}
if (!performClick) {
if (mPackageNames.isEmpty()) {
source.performAction(AccessibilityService.GLOBAL_ACTION_BACK);
}
mHandler.sendEmptyMessage(MSG_PERFORM_STOP);
}
}
示例12: performClick
import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
public static void performClick(AccessibilityNodeInfo nodeInfo,Map<String,String> record, String recordAction, long ms) {
if(nodeInfo == null) return;
if(nodeInfo.isClickable()) {
nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
recordAndLog(record,recordAction);
//record.put("recordAction",recordAction);
//System.out.println("------>"+record);
sleep(ms);
} else {
performClick(nodeInfo.getParent(),record,recordAction,ms);
}
}
示例13: performClick
import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
/**
* 模擬點擊(如果該節點不可點擊,事件分發原理,嘗試遞歸其所有parent節點)
* @param nodeInfo
*/
public static void performClick(AccessibilityNodeInfo nodeInfo){
if(nodeInfo == null) {
return;
}
if(nodeInfo.isClickable()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
nodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
} else {
performClick(nodeInfo.getParent());
}
}
示例14: doClick
import android.view.accessibility.AccessibilityNodeInfo; //導入方法依賴的package包/類
/**
* 執行點擊
*
* @param infos
*/
private void doClick(List<AccessibilityNodeInfo> infos) {
if (infos != null)
for (AccessibilityNodeInfo info : infos) {
if (info.isEnabled() && info.isClickable()) {
Log.i(TAG, "> doClick: " + info.getText());
info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
}
}
示例15: 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;
}