Java Code Examples for android.service.notification.StatusBarNotification#isClearable()
The following examples show how to use
android.service.notification.StatusBarNotification#isClearable() .
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: NotificationCountService.java From Taskbar with Apache License 2.0 | 6 votes |
private void broadcastNotificationCount() { int count = 0; StatusBarNotification[] notifications; try { notifications = getActiveNotifications(); } catch (SecurityException e) { notifications = new StatusBarNotification[0]; } for(StatusBarNotification notification : notifications) { if((notification.getNotification().flags & NotificationCompat.FLAG_GROUP_SUMMARY) == 0 && notification.isClearable()) count++; } broadcastNotificationCount(count); }
Example 2
Source File: NotificationService.java From NotificationPeekPort with Apache License 2.0 | 6 votes |
@Override public void onNotificationPosted(StatusBarNotification sbn) { Notification postedNotification = sbn.getNotification(); if (postedNotification.tickerText == null || sbn.isOngoing() || !sbn.isClearable() || isInBlackList(sbn)) { return; } if (mAppList.isInQuietHour(sbn.getPostTime())) { // The first notification arrived during quiet hour will unregister all sensor listeners. mNotificationPeek.unregisterEventListeners(); return; } mNotificationHub.addNotification(sbn); if (AccessChecker.isDeviceAdminEnabled(this)) { mNotificationPeek .showNotification(sbn, false, mPeekTimeoutMultiplier, mSensorTimeoutMultiplier, mShowContent); } }
Example 3
Source File: Notification.java From Pi-Locker with GNU General Public License v2.0 | 6 votes |
@Override public void onNotificationPosted(StatusBarNotification sbn) { Bundle extras = sbn.getNotification().extras; String title = extras.getString("android.title"); String text = extras.getCharSequence("android.text").toString(); String pack = sbn.getPackageName(); CharSequence ticker = sbn.getNotification().tickerText; boolean ongoing = sbn.isOngoing(); boolean clearable = sbn.isClearable(); Intent msgrcv = new Intent("Msg"); msgrcv.putExtra("title", title); msgrcv.putExtra("text", text); msgrcv.putExtra("p", pack); msgrcv.putExtra("c", clearable); msgrcv.putExtra("o", ongoing); msgrcv.putExtra("t", String.valueOf(ticker)); LocalBroadcastManager.getInstance(context).sendBroadcast(msgrcv); }
Example 4
Source File: NotificationObject.java From android-notification-log with MIT License | 5 votes |
NotificationObject(Context context, StatusBarNotification sbn, final boolean LOG_TEXT, int reason) { this.context = context; this.LOG_TEXT = LOG_TEXT; n = sbn.getNotification(); packageName = sbn.getPackageName(); postTime = sbn.getPostTime(); systemTime = System.currentTimeMillis(); isClearable = sbn.isClearable(); isOngoing = sbn.isOngoing(); nid = sbn.getId(); tag = sbn.getTag(); if(Build.VERSION.SDK_INT >= 20) { key = sbn.getKey(); sortKey = n.getSortKey(); } removeReason = reason; extract(); if(Const.ENABLE_ACTIVITY_RECOGNITION || Const.ENABLE_LOCATION_SERVICE) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); lastActivity = sp.getString(Const.PREF_LAST_ACTIVITY, null); lastLocation = sp.getString(Const.PREF_LAST_LOCATION, null); } }
Example 5
Source File: NotificationService.java From zephyr with MIT License | 5 votes |
private boolean isValidNotification(@NonNull StatusBarNotification sbn) { if (sbn.getPackageName().equals(BuildConfig.APPLICATION_ID)) { logger.log(LogLevel.DEBUG, LOG_TAG, "Invalid notification: Zephyr"); return false; } if (!sbn.isClearable()) { logger.log(LogLevel.DEBUG, LOG_TAG, "Invalid notification: Not clearable"); return false; } if (getPackageManager().getLaunchIntentForPackage(sbn.getPackageName()) == null) { logger.log(LogLevel.DEBUG, LOG_TAG, "Invalid notification: No launch intent"); return false; } INotificationPreference notificationPreference = notificationPreferenceRepository.getNotificationPreferenceSync(sbn.getPackageName()); if (notificationPreference == null) { logger.log(LogLevel.DEBUG, LOG_TAG, "Invalid notification: null preference"); return false; } if (!notificationPreference.isEnabled()) { logger.log(LogLevel.DEBUG, LOG_TAG, "Invalid notification: Disabled"); return false; } logger.log(LogLevel.DEBUG, LOG_TAG, "Valid notification."); return true; }
Example 6
Source File: NotificationListenerService.java From heads-up with GNU General Public License v3.0 | 5 votes |
@Override public void onNotificationPosted(StatusBarNotification statusBarNotification) { try { /* if Show non-cancellable notifications is selected then need not check for Ongoing / Clearable as there will be ongoing notification by the background service which is trying to display. if Show non-cancellable notifications is not selected then existing logic prevails */ if ((statusBarNotification.isOngoing() || !statusBarNotification.isClearable()) && !PreferenceManager.getDefaultSharedPreferences(getApplicationContext()). getBoolean("show_non_cancelable", false)) return; if (NotificationListenerAccessibilityService.doLoadSettings) doLoadSettings(); String statusBarNotificationKey = null; if (Build.VERSION.SDK_INT >= 20) statusBarNotificationKey = statusBarNotification.getKey(); DecisionMaker decisionMaker = new DecisionMaker(); decisionMaker.handleActionAdd(statusBarNotification.getNotification(), statusBarNotification.getPackageName(), statusBarNotification.getTag(), statusBarNotification.getId(), statusBarNotificationKey, getApplicationContext(), "listener"); } catch (NullPointerException e) { e.printStackTrace(); Mlog.e(logTag, "NPE"); } }
Example 7
Source File: NotificationPeek.java From NotificationPeekPort with Apache License 2.0 | 4 votes |
private void showNotification(StatusBarNotification n, boolean update, boolean force) { boolean shouldDisplay = shouldDisplayNotification(n) || force; addNotification(n); if (!mEnabled /* peek is disabled */ || (mPowerManager.isScreenOn() && !mShowing) /* no peek when screen is on */ || !shouldDisplay /* notification has already been displayed */ || !n.isClearable() /* persistent notification */ || mNotificationHelper.isRingingOrConnected() /* is phone ringing? */ || mNotificationHelper.isSimPanelShowing() /* is sim pin lock screen is shown? */) { return; } if (isNotificationActive(n) && (!update || (update && shouldDisplay))) { // update information if (!mShowing) { updateNotificationIcons(); updateSelection(n); } else { mContext.sendBroadcast(new Intent(NotificationPeekActivity. NotificationPeekReceiver.ACTION_UPDATE_NOTIFICATION_ICONS )); } // check if phone is in the pocket or lying on a table if (mSensorHandler.isInPocket() || mSensorHandler.isOnTable()) { if (DEBUG) { Log.d(TAG, "Queueing notification"); } // use partial wakelock to get sensors working if (mPartialWakeLock.isHeld()) { if (DEBUG) { Log.d(TAG, "Releasing partial wakelock"); } mPartialWakeLock.release(); } if (DEBUG) { Log.d(TAG, "Acquiring partial wakelock"); } mPartialWakeLock.acquire(); if (!mEventsRegistered) { mSensorHandler.registerEventListeners(); mEventsRegistered = true; } mWakeLockHandler.removeCallbacks(mPartialWakeLockRunnable); // If always listening is selected, we still release the wake lock in 10 sec, but // we do not unregister sensor listeners. int multiplier = Math.max(1, mSensorTimeoutMultiplier); mWakeLockHandler .postDelayed(mPartialWakeLockRunnable, PARTIAL_WAKELOCK_TIME * multiplier); mNextNotification = n; return; } mWakeLockHandler.removeCallbacks(mPartialWakeLockRunnable); addNotificationView(); // add view instantly if (!mAnimating) { scheduleTasks(); } } }
Example 8
Source File: NotificationLayout.java From NotificationPeekPort with Apache License 2.0 | 4 votes |
@Override public boolean canChildBeDismissed(View v) { StatusBarNotification n = (StatusBarNotification) mNotificationPeek.getNotificationView().getTag(); return n.isClearable(); }