本文整理匯總了Java中android.accessibilityservice.AccessibilityService.getRootInActiveWindow方法的典型用法代碼示例。如果您正苦於以下問題:Java AccessibilityService.getRootInActiveWindow方法的具體用法?Java AccessibilityService.getRootInActiveWindow怎麽用?Java AccessibilityService.getRootInActiveWindow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.accessibilityservice.AccessibilityService
的用法示例。
在下文中一共展示了AccessibilityService.getRootInActiveWindow方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: performBack
import android.accessibilityservice.AccessibilityService; //導入方法依賴的package包/類
/**
* 返回事件
*/
public static void performBack(final AccessibilityService service, AccessibilityNodeInfo nodeInfo) {
CharSequence packageName = nodeInfo.getPackageName();
if (!(packageName+"").equals(WECHAT_PACKAGE_NAME)) {
L.d("不是微信,不能後退 " + packageName);
return;
}
if (service == null) {
L.e("performBackWithDelay service is null");
return;
}
if (service.getRootInActiveWindow() == null) {
L.e("performBackWithDelay rootNode is null");
return;
}
L.d("performBack Reboot ");
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
}
示例2: findTextAndClick
import android.accessibilityservice.AccessibilityService; //導入方法依賴的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;
}
}
}
}
示例3: findViewIdAndClick
import android.accessibilityservice.AccessibilityService; //導入方法依賴的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;
}
}
}
}
示例4: findDialogAndClick
import android.accessibilityservice.AccessibilityService; //導入方法依賴的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;
}
}
}
}
示例5: fineNodeByIdAndTextCheck
import android.accessibilityservice.AccessibilityService; //導入方法依賴的package包/類
public static AccessibilityNodeInfo fineNodeByIdAndTextCheck(AccessibilityNodeInfo node,String id,String text,
AccessibilityService context,Map<String,String> record, String recordAction){
AccessibilityNodeInfo result = null;
int count=0;
while (count<6){
node = context.getRootInActiveWindow();
if(text==null){
result = findNodeInfosById(node,id);
}else if(id==null){
result = findNodeInfosByText(node,text);
}else{
result = fineNodeByIdAndText(node,id,text);
}
if(result!=null)
break;
count = count +1;
sleep(500*count);
}
if(result==null)
recordAndLog(record,recordAction);
return result;
}
示例6: click
import android.accessibilityservice.AccessibilityService; //導入方法依賴的package包/類
@Override
public void click(AccessibilityService context, AccessibilityEvent event, WeChatLuckMoney money) {
System.out.println("StateMoneyReceived");
money.sleep();
AccessibilityNodeInfo info = context.getRootInActiveWindow();
if (info == null) {
System.out.println("StateMoneyReceived is null");
back(context, money);
return;
}
List<AccessibilityNodeInfo> node3 = info.findAccessibilityNodeInfosByText("紅包詳情");
List<AccessibilityNodeInfo> node4 = info.findAccessibilityNodeInfosByText("手慢了");
if (!node3.isEmpty() || !node4.isEmpty()) {
System.out.println("StateMoneyReceived has 紅包詳情");
back(context, money);
}
money.setState(money.messageComing);
}
示例7: performHome
import android.accessibilityservice.AccessibilityService; //導入方法依賴的package包/類
/**
* 返回事件
*/
public static void performHome(final AccessibilityService service) {
if (service == null) {
L.e("performBackWithDelay service is null");
return;
}
if (service.getRootInActiveWindow() == null) {
L.e("performBackWithDelay rootNode is null");
return;
}
L.d("performHome");
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME);
}
示例8: performClickAndExpect
import android.accessibilityservice.AccessibilityService; //導入方法依賴的package包/類
public static void performClickAndExpect(AccessibilityNodeInfo nodeInfo,Map<String,String> record, String recordAction
,AccessibilityService context,AccessibilityNodeInfo rootNode,String id,String text) {
performClick(nodeInfo,record,recordAction);
if(rootNode==null) return;
rootNode = context.getRootInActiveWindow();
if(id!=null&&text!=null){
}
}
示例9: getFocusedNode
import android.accessibilityservice.AccessibilityService; //導入方法依賴的package包/類
public static AccessibilityNodeInfoCompat getFocusedNode(
AccessibilityService service, boolean fallbackOnRoot) {
AccessibilityNodeInfo root =
service.getRootInActiveWindow();
AccessibilityNodeInfo focused = null;
try {
AccessibilityNodeInfo ret = null;
if (root != null) {
focused = root.findFocus(
AccessibilityNodeInfo.FOCUS_ACCESSIBILITY);
if (focused != null && focused.isVisibleToUser()) {
ret = focused;
focused = null;
} else if (fallbackOnRoot) {
ret = root;
root = null;
}
} else {
LogUtils.log(service, Log.ERROR, "No current window root");
}
if (ret != null) {
return new AccessibilityNodeInfoCompat(ret);
}
} finally {
if (root != null) {
root.recycle();
}
if (focused != null) {
focused.recycle();
}
}
return null;
}
示例10: getRootInActiveWindow
import android.accessibilityservice.AccessibilityService; //導入方法依賴的package包/類
/**
* @return root node of the Application window
*/
public static AccessibilityNodeInfoCompat getRootInActiveWindow(AccessibilityService service) {
if(service == null) return null;
AccessibilityNodeInfo root = service.getRootInActiveWindow();
if (root == null) return null;
return new AccessibilityNodeInfoCompat(root);
}
示例11: getRootInAccessibilityFocusedWindow
import android.accessibilityservice.AccessibilityService; //導入方法依賴的package包/類
/**
* @return root node of the window that currently has accessibility focus
*/
public static AccessibilityNodeInfoCompat getRootInAccessibilityFocusedWindow(
AccessibilityService service) {
if (service == null) {
return null;
}
AccessibilityNodeInfo focusedRoot = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
List<AccessibilityWindowInfo> windows = service.getWindows();
// Create window manager with fake value of isInRTL = false. This is okay here since
// isInRTL will not change the result of getCurrentWindow.
WindowManager manager = new WindowManager(false /* isInRTL */);
manager.setWindows(windows);
AccessibilityWindowInfo accessibilityFocusedWindow =
manager.getCurrentWindow(false /* useInputFocus */);
if (accessibilityFocusedWindow != null) {
focusedRoot = accessibilityFocusedWindow.getRoot();
}
}
if (focusedRoot == null) {
focusedRoot = service.getRootInActiveWindow();
}
if (focusedRoot == null) {
return null;
}
return new AccessibilityNodeInfoCompat(focusedRoot);
}
示例12: getFocusedNode
import android.accessibilityservice.AccessibilityService; //導入方法依賴的package包/類
public static AccessibilityNodeInfoCompat getFocusedNode(AccessibilityService service,
boolean fallbackOnRoot) {
AccessibilityNodeInfo root = service.getRootInActiveWindow();
AccessibilityNodeInfo focused = null;
try {
AccessibilityNodeInfo ret = null;
if (root != null) {
focused = root.findFocus(AccessibilityNodeInfo.FOCUS_ACCESSIBILITY);
if (focused != null && focused.isVisibleToUser()) {
ret = focused;
focused = null;
} else if (fallbackOnRoot) {
ret = root;
root = null;
}
} else {
LogUtils.log(service, Log.ERROR, "No current window root");
}
if (ret != null) {
return new AccessibilityNodeInfoCompat(ret);
}
} finally {
if (root != null) {
root.recycle();
}
if (focused != null) {
focused.recycle();
}
}
return null;
}
示例13: click
import android.accessibilityservice.AccessibilityService; //導入方法依賴的package包/類
@Override
public void click(AccessibilityService context, AccessibilityEvent event, WeChatLuckMoney money) {
System.out.println("StateMoneyOpen");
money.sleep();
AccessibilityNodeInfo info = context.getRootInActiveWindow();
if (info == null) {
System.out.println("StateMoneyOpen info is null");
back(context, money);
return;
}
List<AccessibilityNodeInfo> node = info.findAccessibilityNodeInfosByText("拆紅包");
final int size = node.size();
System.out.println("StateMoneyOpen size:" + size);
if (size > 0) {
System.out.println("StateMoneyOpen open money");
AccessibilityNodeInfo cellNode = node.get(size - 1);
money.sleep();
cellNode.performAction(AccessibilityNodeInfo.ACTION_CLICK);
cellNode.recycle();
money.setState(money.moneyReceived);
} else {
System.out.println("StateMoneyOpen no open money");
List<AccessibilityNodeInfo> node3 = info.findAccessibilityNodeInfosByText("紅包詳情");
List<AccessibilityNodeInfo> node4 = info.findAccessibilityNodeInfosByText("手慢了");
if (!node3.isEmpty() || !node4.isEmpty()) {
System.out.println("StateMoneyOpen has 紅包詳情");
back(context, money);
} else {
System.out.println("StateMoneyOpen not has 紅包詳情");
money.setState(money.messageComing);
}
// back (context, money);
}
}