本文整理匯總了Java中android.accessibilityservice.AccessibilityService類的典型用法代碼示例。如果您正苦於以下問題:Java AccessibilityService類的具體用法?Java AccessibilityService怎麽用?Java AccessibilityService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AccessibilityService類屬於android.accessibilityservice包,在下文中一共展示了AccessibilityService類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onAccessibilityEvent
import android.accessibilityservice.AccessibilityService; //導入依賴的package包/類
@Override
public boolean onAccessibilityEvent(AccessibilityService service, AccessibilityEvent event) {
if (event.getParcelableData() instanceof Notification) {
Notification notification = (Notification) event.getParcelableData();
Log.d(TAG, "onNotification: " + notification + "; " + event);
onNotification(event, notification);
} else {
List<CharSequence> list = event.getText();
Log.d(TAG, "onNotification: " + list + "; " + event);
if (event.getPackageName().equals(mContext.getPackageName())) {
return false;
}
if (list != null) {
onNotification(event, new NotificationInfo(event.getPackageName(), list));
}
}
return false;
}
開發者ID:feifadaima,項目名稱:https-github.com-hyb1996-NoRootScriptDroid,代碼行數:19,代碼來源:NotificationListener.java
示例2: isAccessibilityServiceEnabled
import android.accessibilityservice.AccessibilityService; //導入依賴的package包/類
public static boolean isAccessibilityServiceEnabled(Context context, Class<? extends AccessibilityService> accessibilityService) {
ComponentName expectedComponentName = new ComponentName(context, accessibilityService);
String enabledServicesSetting = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
if (enabledServicesSetting == null)
return false;
TextUtils.SimpleStringSplitter colonSplitter = new TextUtils.SimpleStringSplitter(':');
colonSplitter.setString(enabledServicesSetting);
while (colonSplitter.hasNext()) {
String componentNameString = colonSplitter.next();
ComponentName enabledService = ComponentName.unflattenFromString(componentNameString);
if (enabledService != null && enabledService.equals(expectedComponentName))
return true;
}
return false;
}
開發者ID:feifadaima,項目名稱:https-github.com-hyb1996-NoRootScriptDroid,代碼行數:21,代碼來源:AccessibilityServiceUtils.java
示例3: doSMZDM
import android.accessibilityservice.AccessibilityService; //導入依賴的package包/類
public void doSMZDM(AccessibilityService service) {
autoLock.lock();
try {
delay(8000);
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
delay(4000);
Utils.reLaunch(service, SMZDM);
delay(4000);
iteratorSMZDM(service.getRootInActiveWindow());
autoCondition.await(10, TimeUnit.SECONDS); // 10s
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
delay(2000);
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
delay(2000);
} catch (Exception e) {
e.printStackTrace();
}
autoLock.unlock();
MainPage.condition.signal();
}
示例4: doTXDM
import android.accessibilityservice.AccessibilityService; //導入依賴的package包/類
public void doTXDM(AccessibilityService service) {
autoLock.lock();
try {
delay(6000);
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
delay(4000);
Utils.reLaunch(service, TXDM);
delay(4000);
iteratorTXDM(service.getRootInActiveWindow(), service);
delay(1000);
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
delay(2000);
} catch (Exception e) {
e.printStackTrace();
}
autoLock.unlock();
MainPage.condition.signal();
}
示例5: iterator
import android.accessibilityservice.AccessibilityService; //導入依賴的package包/類
private void iterator(AccessibilityNodeInfo info, AccessibilityService service) {
if (info.getText() != null) {
if (info.getText().equals("簽到") && info.isClickable()) {
info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
delay(3000);
iterator(service.getRootInActiveWindow(), service);
found = true;
return;
}
} else {
for (int i = 0; i < info.getChildCount(); i++) {
if(info.getChild(i)!=null){
if (found) {
found = false;
break;
}
iterator(info.getChild(i), service);
}
}
}
return ;
}
示例6: iteratorTXDM
import android.accessibilityservice.AccessibilityService; //導入依賴的package包/類
private void iteratorTXDM(AccessibilityNodeInfo info, AccessibilityService service) {
List<AccessibilityNodeInfo> node = info.findAccessibilityNodeInfosByViewId("com.qq.ac.android:id/tab_layout_center");
if (node != null) {
AccessibilityNodeInfo find = node.get(0);
if ("android.widget.RelativeLayout".equals(find.getClassName())
&& find.isClickable()) {
find.performAction(AccessibilityNodeInfo.ACTION_CLICK);
delay(3000);
iterator(service.getRootInActiveWindow(), service);
found = true;
return;
}
} else {
for (int i = 0; i < info.getChildCount(); i++) {
if(info.getChild(i)!=null){
if (found) {
found = false;
break;
}
iteratorTXDM(info.getChild(i), service);
}
}
}
return ;
}
示例7: openHongBao
import android.accessibilityservice.AccessibilityService; //導入依賴的package包/類
private void openHongBao(AccessibilityEvent event){
String className=event.getClassName().toString();
Log.i(TAG,className);
if(className.equals(QQ_CLASSNAME_WALLET)&&isNeedBack){
performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
isNeedBack=false;
}else if(className.equals(QQ_CLASSNAME_CHAT)||(event.getEventType()==AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED&&windowState)) {
//wakeAndUnlock(true);
windowState=true;
if(!runState){
AccessibilityNodeInfo info = event.getSource();
if(info == null) return;
getAllHongBao(info);
}
}else{
windowState=false;
}
}
示例8: 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);
}
示例9: inputText
import android.accessibilityservice.AccessibilityService; //導入依賴的package包/類
public static void inputText(Context context, AccessibilityService service, AccessibilityNodeInfo nodeInfo,
final String hello) {
//找到當前獲取焦點的view
// AccessibilityNodeInfo target = nodeInfo.findFocus(AccessibilityNodeInfo.FOCUS_INPUT);
AccessUtil.findNodeInfosByName(nodeInfo, "android.widget.EditText");
AccessibilityNodeInfo target = editText;
if (target == null) {
L.d("inputHello: null");
return;
} else {
L.d("inputHello: not null " + target.getText());
}
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("message", hello);
clipboard.setPrimaryClip(clip);
L.d("設置粘貼板");
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
// target.performAction(AccessibilityNodeInfo.ACTION_PASTE);
// }
target.performAction(AccessibilityNodeInfo.ACTION_FOCUS);
L.d("獲取焦點");
target.performAction(AccessibilityNodeInfo.ACTION_PASTE);
L.d("粘貼內容");
// openNext2("發送", nodeInfo, service);//點擊發送
}
示例10: inputText2
import android.accessibilityservice.AccessibilityService; //導入依賴的package包/類
public static boolean inputText2(Context context, AccessibilityService service, AccessibilityNodeInfo nodeInfo,
final String hello) {
//找到當前獲取焦點的view
// AccessibilityNodeInfo target = nodeInfo.findFocus(AccessibilityNodeInfo.FOCUS_INPUT);
AccessUtil.findNodeInfosByName(nodeInfo, "android.widget.EditText");
AccessibilityNodeInfo target = editText;
if (target == null) {
L.d("inputHello: null");
return false;
} else {
L.d("inputHello: not null " + target.getText());
}
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("message", hello);
clipboard.setPrimaryClip(clip);
L.d("設置粘貼板");
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
// target.performAction(AccessibilityNodeInfo.ACTION_PASTE);
// }
target.performAction(AccessibilityNodeInfo.ACTION_FOCUS);
L.d("獲取焦點");
target.performAction(AccessibilityNodeInfo.ACTION_PASTE);
L.d("粘貼內容");
return true;
}
示例11: openNext2
import android.accessibilityservice.AccessibilityService; //導入依賴的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;
}
}
示例12: 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;
}
}
}
}
示例13: 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;
}
}
}
}
示例14: 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;
}
}
}
}
示例15: checkAccessibilityEnabled
import android.accessibilityservice.AccessibilityService; //導入依賴的package包/類
/**
* 檢測當前輔助服務是否開啟
*/
public static boolean checkAccessibilityEnabled(Context context,Class<? extends AccessibilityService> clazz) {
int accessibilityEnabled = 0;
final String service = context.getPackageName() + "/" + clazz.getCanonicalName();
try {
accessibilityEnabled = Settings.Secure.getInt(context.getApplicationContext().getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED);
} catch (Settings.SettingNotFoundException ignored) {
// ignored
}
TextUtils.SimpleStringSplitter stringColonSplitter = new TextUtils.SimpleStringSplitter(':');
if (accessibilityEnabled == 1) {
String settingValue = Settings.Secure.getString(context.getApplicationContext().getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
if (settingValue != null) {
stringColonSplitter.setString(settingValue);
while (stringColonSplitter.hasNext()) {
String accessibilityService = stringColonSplitter.next();
if (accessibilityService.equalsIgnoreCase(service)) {
return true;
}
}
}
}
return false;
}