本文整理汇总了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;
}