本文整理匯總了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;
}
}