Java Code Examples for android.view.accessibility.AccessibilityEvent#TYPE_NOTIFICATION_STATE_CHANGED
The following examples show how to use
android.view.accessibility.AccessibilityEvent#TYPE_NOTIFICATION_STATE_CHANGED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccessibilityService.java From AcDisplay with GNU General Public License v2.0 | 6 votes |
@Override public void onAccessibilityEvent(AccessibilityEvent event) { switch (event.getEventType()) { case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED: Parcelable parcelable = event.getParcelableData(); if (parcelable instanceof Notification) { if (Device.hasJellyBeanMR2Api()) { // No need to use the accessibility service // instead of NotificationListener. return; } Notification notification = (Notification) parcelable; OpenNotification openNotification = OpenNotification.newInstance(notification); NotificationPresenter.getInstance().postNotificationFromMain(this, openNotification, 0); } break; } }
Example 2
Source File: LgcAccessibilityService.java From live-group-chat with GNU Affero General Public License v3.0 | 6 votes |
@Override public void onAccessibilityEvent(AccessibilityEvent event) { if (!enabled) { return; } if (AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED == event.getEventType()) { Notification notification = (Notification) event.getParcelableData(); if (notification != null) { LogUtils.d(TAG, "receive notification from " + event.getPackageName() + "|title is " + notification.tickerText); LgcApp.getInstance().onNotification(event.getPackageName(), notification, System.currentTimeMillis()); } } else if (AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED == event.getEventType()) { // find in android sources event.getPackageName() will not be null, but crash collect // show it is may be null CharSequence package_name = event.getPackageName(); if (package_name != null) { LogUtils.d(TAG, "current package is : " + package_name); } } }
Example 3
Source File: AccessibilityService.java From Status with Apache License 2.0 | 6 votes |
@Override protected void onServiceConnected() { super.onServiceConnected(); packageManager = getPackageManager(); volumeReceiver = new VolumeReceiver(this); registerReceiver(volumeReceiver, new IntentFilter("android.media.VOLUME_CHANGED_ACTION")); notifications = new ArrayList<>(); AccessibilityServiceInfo config = new AccessibilityServiceInfo(); config.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED | AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; config.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) config.flags = AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS; setServiceInfo(config); }
Example 4
Source File: NotificationService.java From pebble-notifier with MIT License | 6 votes |
@Override protected void onServiceConnected() { // get inital preferences watchFile = new File(getFilesDir() + "PrefsChanged.none"); if (!watchFile.exists()) { try { watchFile.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } watchFile.setLastModified(System.currentTimeMillis()); } loadPrefs(); AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.feedbackType = AccessibilityServiceInfo.FEEDBACK_VISUAL; info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; info.notificationTimeout = 100; setServiceInfo(info); mHandler = new Handler(); queue = new LinkedList<queueItem>(); }
Example 5
Source File: AccessibilityService.java From HeadsUp with GNU General Public License v2.0 | 6 votes |
@Override public void onAccessibilityEvent(AccessibilityEvent event) { switch (event.getEventType()) { case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED: Parcelable parcelable = event.getParcelableData(); if (parcelable instanceof Notification) { if (Device.hasJellyBeanMR2Api()) { // No need to use the accessibility service // instead of NotificationListener. return; } Notification notification = (Notification) parcelable; OpenNotification openNotification = OpenNotification.newInstance(notification); NotificationPresenter.getInstance().postNotificationFromMain(this, openNotification, 0); } break; } }
Example 6
Source File: NotificationUpdateServiceOld.java From deskcon-android with GNU General Public License v3.0 | 6 votes |
@Override public void onAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) { Notification not = (Notification) event.getParcelableData(); // permissions boolean send_other_notifications = sharedPrefs.getBoolean("send_other_notifications", false); ArrayList<String> whitelist = getNotificationWhitelist(); String packagename = String.valueOf(event.getPackageName()); if (not != null && send_other_notifications && whitelist.contains(packagename)) { Log.d("Notification: ", "new post"); if (not.tickerText != null) { String text = not.tickerText.toString(); startUpdateServiceCommand(text); } } } }
Example 7
Source File: PushMonitorAccessibilityService.java From NewsPushMonitor with Apache License 2.0 | 5 votes |
@Override public void onAccessibilityEvent(AccessibilityEvent accessibilityEvent) { int type = accessibilityEvent.getEventType(); if (type != AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) { return; } String pkg = accessibilityEvent.getPackageName().toString(); long time = accessibilityEvent.getEventTime(); Notification notification = (Notification) accessibilityEvent.getParcelableData(); List<CharSequence> texts = accessibilityEvent.getText(); StringBuilder sb = new StringBuilder(); for (CharSequence text : texts) { sb.append(text).append("###"); } LogWriter.i(TAG, "onAccessibilityEvent " + "package=" + pkg + ",time=" + time + ",text=" + sb.toString()); LogWriter.i(TAG, "Parse notification for " + pkg + " begin!"); BaseNotificationParser notificationParser = NotificationParserFactory.getNotificationParser(pkg); BaseNotificationParser.NewsInfo newsInfo = notificationParser.parse(notification); LogWriter.i(TAG, "when:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(newsInfo.when)); LogWriter.i(TAG, "ContentTitle:" + newsInfo.contentTitle); LogWriter.i(TAG, "ContentText:" + newsInfo.contentText); LogWriter.i(TAG, "Url:" + newsInfo.url); LogWriter.i(TAG, "Parse notification for " + pkg + " end!"); LogWriter.i(TAG, "##################################################################"); commitNewsInfoToServer(newsInfo); showNewsInfo(newsInfo); }
Example 8
Source File: AccessibilityService.java From HeadsUp with GNU General Public License v2.0 | 5 votes |
@Override public void onServiceConnected() { AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC; info.notificationTimeout = 100; setServiceInfo(info); }
Example 9
Source File: TestAccessibilityService.java From EasyProtector with Apache License 2.0 | 5 votes |
@Override public void onAccessibilityEvent(AccessibilityEvent event) { int eventType = event.getEventType(); switch (eventType) { case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:// 通知栏事件 case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:// //切换页面的时候触发 break; } if (event.getPackageName().toString().equals("com.android.packageinstaller")) { installAPK(event); } }
Example 10
Source File: dex_smali.java From styT with Apache License 2.0 | 5 votes |
@Override public void onAccessibilityEvent(AccessibilityEvent event) { SharedPreferences sharedPreferences = getSharedPreferences("nico.styTool_preferences", MODE_PRIVATE); boolean isFirstRun = sharedPreferences.getBoolean("ok_c", true); //Editor editor = sharedPreferences.edit(); if (isFirstRun) { NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.mipmap.ic_launcher); builder.setContentTitle("妮哩"); builder.setContentText("QQ抢红包正在运行"); builder.setOngoing(true); Notification notification = builder.build(); NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); manager.notify(NOTIFICATION_ID, notification); } else { } if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) { List<CharSequence> texts = event.getText(); if (!texts.isEmpty()) { for (CharSequence text : texts) { String content = text.toString(); if (content.contains(QQ_KEYWORD_NOTIFICATION)) { openNotify(event); return; } } } } openHongBao(event); }
Example 11
Source File: dili.java From styT with Apache License 2.0 | 5 votes |
@Override public void onAccessibilityEvent(AccessibilityEvent event) { SharedPreferences sharedPreferences = getSharedPreferences("nico.styTool_preferences", MODE_PRIVATE); boolean isFirstRun = sharedPreferences.getBoolean("ok_c", true); //Editor editor = sharedPreferences.edit(); if (isFirstRun) { NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setSmallIcon(R.mipmap.ic_launcher); builder.setContentTitle("妮哩"); builder.setContentText("Tim抢红包正在运行"); builder.setOngoing(true); Notification notification = builder.build(); NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); manager.notify(NOTIFICATION_ID, notification); } else { } if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) { List<CharSequence> texts = event.getText(); if (!texts.isEmpty()) { for (CharSequence text : texts) { String content = text.toString(); if (content.contains(QQ_KEYWORD_NOTIFICATION)) { openNotify(event); return; } } } } openHongBao(event); }
Example 12
Source File: NotificationListener.java From appium-uiautomator2-server with Apache License 2.0 | 5 votes |
@Override public synchronized void onAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) { Logger.debug("Catch toast message: " + event); List<CharSequence> text = event.getText(); if (text != null && !text.isEmpty()) { setToastMessage(text); } } if (originalListener != null) { originalListener.onAccessibilityEvent(event); } }
Example 13
Source File: BotifierAccessibilityService.java From Botifier with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void onServiceConnected() { super.onServiceConnected(); AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED | AccessibilityEvent.TYPE_ANNOUNCEMENT; info.feedbackType = AccessibilityServiceInfo.FEEDBACK_ALL_MASK; setServiceInfo(info); }
Example 14
Source File: AccessibilityService.java From AcDisplay with GNU General Public License v2.0 | 5 votes |
@Override public void onServiceConnected() { AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC; info.notificationTimeout = 100; setServiceInfo(info); }
Example 15
Source File: BotifierAccessibilityService.java From Botifier with BSD 2-Clause "Simplified" License | 5 votes |
public void onAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) { Notification notification = (Notification) event.getParcelableData(); if (notification == null ) { return; } sendCmd(event, notification, NotificationEvents.NOTIFICATION_ADDED); } }
Example 16
Source File: LgcAccessibilityService.java From live-group-chat with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void onServiceConnected() { super.onServiceConnected(); run = true; if (Build.VERSION.SDK_INT < 14) { AccessibilityServiceInfo serverInfo = new AccessibilityServiceInfo(); serverInfo.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED | AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; serverInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_VISUAL; serverInfo.flags = AccessibilityServiceInfo.DEFAULT; serverInfo.notificationTimeout = 0L; setServiceInfo(serverInfo); } }
Example 17
Source File: NotificationListenerAccessibilityService.java From heads-up with GNU General Public License v3.0 | 4 votes |
@Override protected void onServiceConnected() { PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) .edit() .putBoolean("running", true) .apply(); if (isInit) return; AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; info.feedbackType = AccessibilityServiceInfo.FEEDBACK_VISUAL; info.flags = AccessibilityServiceInfo.DEFAULT; setServiceInfo(info); isInit = true; doLoadSettings(); if (Build.VERSION.SDK_INT >= 18) { Intent intent = new Intent(); intent.setClass(getApplicationContext(), OverlayServiceCommon.class); intent.setAction("STAY"); intent.putExtra("packageName", getPackageName()); intent.putExtra("title", getString(R.string.app_name)); if (isNotificationListenerEnabled()) intent.putExtra("text", getString(R.string.intro_warning_both_services)); else { final String str = getString(R.string.accessibility_desc); intent.putExtra("text", str.substring(str.lastIndexOf("\n") + 1)); } intent.putExtra("action", PendingIntent.getActivity(getApplicationContext(), 0, new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS), 0)); if (Build.VERSION.SDK_INT >= 11) { Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_dismiss_white); intent.putExtra("iconLarge", bitmap); } intent.putExtra("icon", R.drawable.ic_dismiss_white); startService(intent); stopSelf(); } }
Example 18
Source File: WeChatAccessService.java From pc-android-controller-android with Apache License 2.0 | 4 votes |
@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; } }
Example 19
Source File: AccessibilityEventUtils.java From talkback with Apache License 2.0 | 4 votes |
public static String typeToString(int eventType) { switch (eventType) { case AccessibilityEvent.TYPE_ANNOUNCEMENT: return "TYPE_ANNOUNCEMENT"; case AccessibilityEvent.TYPE_ASSIST_READING_CONTEXT: return "TYPE_ASSIST_READING_CONTEXT"; case AccessibilityEvent.TYPE_GESTURE_DETECTION_END: return "TYPE_GESTURE_DETECTION_END"; case AccessibilityEvent.TYPE_GESTURE_DETECTION_START: return "TYPE_GESTURE_DETECTION_START"; case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED: return "TYPE_NOTIFICATION_STATE_CHANGED"; case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END: return "TYPE_TOUCH_EXPLORATION_GESTURE_END"; case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START: return "TYPE_TOUCH_EXPLORATION_GESTURE_START"; case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END: return "TYPE_TOUCH_INTERACTION_END"; case AccessibilityEvent.TYPE_TOUCH_INTERACTION_START: return "TYPE_TOUCH_INTERACTION_START"; case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: return "TYPE_VIEW_ACCESSIBILITY_FOCUSED"; case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED: return "TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED"; case AccessibilityEvent.TYPE_VIEW_CLICKED: return "TYPE_VIEW_CLICKED"; case AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED: return "TYPE_VIEW_CONTEXT_CLICKED"; case AccessibilityEvent.TYPE_VIEW_FOCUSED: return "TYPE_VIEW_FOCUSED"; case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER: return "TYPE_VIEW_HOVER_ENTER"; case AccessibilityEvent.TYPE_VIEW_HOVER_EXIT: return "TYPE_VIEW_HOVER_EXIT"; case AccessibilityEvent.TYPE_VIEW_LONG_CLICKED: return "TYPE_VIEW_LONG_CLICKED"; case AccessibilityEvent.TYPE_VIEW_SCROLLED: return "TYPE_VIEW_SCROLLED"; case AccessibilityEvent.TYPE_VIEW_SELECTED: return "TYPE_VIEW_SELECTED"; case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED: return "TYPE_VIEW_TEXT_CHANGED"; case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED: return "TYPE_VIEW_TEXT_SELECTION_CHANGED"; case AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY: return "TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY"; case AccessibilityEvent.TYPE_WINDOWS_CHANGED: return "TYPE_WINDOWS_CHANGED"; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: return "TYPE_WINDOW_CONTENT_CHANGED"; case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: return "TYPE_WINDOW_STATE_CHANGED"; default: return "(unhandled)"; } }
Example 20
Source File: AccessibilityUtils.java From DevUtils with Apache License 2.0 | 4 votes |
/** * 打印 AccessibilityEvent 信息日志 * @param event {@link AccessibilityEvent} * @param tag 日志 TAG */ public static void printAccessibilityEvent(final AccessibilityEvent event, final String tag) { if (event == null || !LogPrintUtils.isPrintLog()) return; StringBuilder builder = new StringBuilder(); builder.append("========================="); builder.append(NEW_LINE_STR); int eventType = event.getEventType(); // 事件类型 builder.append("packageName: " + event.getPackageName() + ""); // 响应事件的应用包名 builder.append(NEW_LINE_STR); builder.append("source: " + event.getSource() + ""); // 事件源信息 builder.append(NEW_LINE_STR); builder.append("source class: " + event.getClassName() + ""); // 事件源的类名, 如 android.widget.TextView builder.append(NEW_LINE_STR); builder.append("event type(int): " + eventType + ""); builder.append(NEW_LINE_STR); switch (eventType) { case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:// 通知栏事件 builder.append("event type: TYPE_NOTIFICATION_STATE_CHANGED"); break; case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: // 窗体状态改变 builder.append("event type: TYPE_WINDOW_STATE_CHANGED"); break; case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: // View 获取到焦点 builder.append("event type: TYPE_VIEW_ACCESSIBILITY_FOCUSED"); break; case AccessibilityEvent.TYPE_GESTURE_DETECTION_START: builder.append("event type: TYPE_VIEW_ACCESSIBILITY_FOCUSED"); break; case AccessibilityEvent.TYPE_GESTURE_DETECTION_END: builder.append("event type: TYPE_GESTURE_DETECTION_END"); break; case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED: builder.append("event type: TYPE_WINDOW_CONTENT_CHANGED"); break; case AccessibilityEvent.TYPE_VIEW_CLICKED: builder.append("event type: TYPE_VIEW_CLICKED"); break; case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED: builder.append("event type: TYPE_VIEW_TEXT_CHANGED"); break; case AccessibilityEvent.TYPE_VIEW_SCROLLED: builder.append("event type: TYPE_VIEW_SCROLLED"); break; case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED: builder.append("event type: TYPE_VIEW_TEXT_SELECTION_CHANGED"); break; } builder.append(NEW_LINE_STR); for (CharSequence txt : event.getText()) { // 输出当前事件包含的文本信息 builder.append("text: " + txt); builder.append(NEW_LINE_STR); } builder.append("========================="); // 打印日志 LogPrintUtils.dTag(tag, builder.toString()); }