本文整理汇总了Java中android.view.accessibility.AccessibilityNodeInfo.getPackageName方法的典型用法代码示例。如果您正苦于以下问题:Java AccessibilityNodeInfo.getPackageName方法的具体用法?Java AccessibilityNodeInfo.getPackageName怎么用?Java AccessibilityNodeInfo.getPackageName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.accessibility.AccessibilityNodeInfo
的用法示例。
在下文中一共展示了AccessibilityNodeInfo.getPackageName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performBack
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的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: onAccessibilityEvent
import android.view.accessibility.AccessibilityNodeInfo; //导入方法依赖的package包/类
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
super.onAccessibilityEvent(event);
AccessibilityNodeInfo rootInActiveWindow = getRootInActiveWindow();
if (rootInActiveWindow == null) {
L.d("openContactInfo nodeInfo is null");
return;
}
L.d("得到当前包名 "+rootInActiveWindow.getPackageName() + " 类名 " + rootInActiveWindow.getClass());
if (rootInActiveWindow.getPackageName() != null &&
!(rootInActiveWindow.getPackageName() + "").equals("com.tencent.mm")) {
L.e("不是 微信 返回");
return;
}
if (mIsNeedCloseWeChat) {
if (rootInActiveWindow.getPackageName() != null &&
(rootInActiveWindow.getPackageName() + "").equals(AccessUtil.WECHAT_PACKAGE_NAME)) {
if (AccessUtil.isWeChatMain(rootInActiveWindow)) {
mIsNeedCloseWeChat = false;
L.d("ismain");
mActivity.startActivity(mIntent);
} else {
AccessUtil.performBack(this, rootInActiveWindow);
}
return;
} else {
// mIsNeedCloseWeChat = false;
// if (mIntent != null && mActivity != null) {
// mActivity.startActivity(mIntent);
// }
}
}
int eventType = event.getEventType();
switch (eventType) {
//第一步:监听通知栏消息
case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:
WeChatMsg.sendNotify(event);
break;
//第二步:监听是否进入微信聊天界面
case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
// WeChatNearly.nearly(this, getRootInActiveWindow(), this, "你好");
L.d("type " + type);
switch (type) {
case Mode.autoHello://自动打招呼
mWeChatNearly.change(this, rootInActiveWindow, this, "你好");
break;
case Mode.group://群发
mWeChatGroup.change(this, rootInActiveWindow, this, "你好");
break;
case Mode.autoChat://自动聊天
mWeChatAutoReply.change(this, rootInActiveWindow, this, "你好");
break;
case Mode.closeService://无法实现
AccessUtil.openNext(rootInActiveWindow, "测试");
break;
}
break;
default:
break;
}
}