android.service.notification.StatusBarNotification Java Examples

The following examples show how to use android.service.notification.StatusBarNotification. 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: NotificationUtils.java    From HeadsUp with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Dismisses given notification from system and app.
 */
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
public static void dismissNotification(@NonNull OpenNotification n) {
    NotificationPresenter.getInstance().removeNotification(n);
    StatusBarNotification sbn = n.getStatusBarNotification();
    if (sbn != null && Device.hasJellyBeanMR2Api()) {
        MediaService service = MediaService.sService;
        if (service != null) {
            if (Device.hasLollipopApi()) {
                service.cancelNotification(sbn.getKey());
            } else {
                service.cancelNotification(
                        sbn.getPackageName(),
                        sbn.getTag(),
                        sbn.getId());
            }
        } else {
            Log.e(TAG, "Failed to dismiss notification because notification service is offline.");
        }
    }
}
 
Example #2
Source File: ProgressBarController.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private ProgressInfo verifyNotification(StatusBarNotification statusBarNotif) {
    if (statusBarNotif == null)
        return null;

    String id = getIdentifier(statusBarNotif);
    if (id == null)
        return null;

    Notification n = statusBarNotif.getNotification();
    if (n != null && 
           (SUPPORTED_PACKAGES.contains(statusBarNotif.getPackageName()) ||
            n.extras.getBoolean(ModLedControl.NOTIF_EXTRA_PROGRESS_TRACKING))) {
        ProgressInfo pi = getProgressInfo(id, n);
        if (pi != null && pi.hasProgressBar)
            return pi;
    }
    return null;
}
 
Example #3
Source File: NotificationHelper.java    From NotificationPeekPort with Apache License 2.0 6 votes vote down vote up
public static boolean shouldDisplayNotification(StatusBarNotification oldNotif,
                                                StatusBarNotification newNotif) {
    // First check for ticker text, if they are different, some other parameters will be
    // checked to determine if we should show the notification.
    CharSequence oldTickerText = oldNotif.getNotification().tickerText;
    CharSequence newTickerText = newNotif.getNotification().tickerText;
    if (newTickerText == null ? oldTickerText == null : newTickerText.equals(oldTickerText)) {
        // If old notification title isn't null, show notification if
        // new notification title is different. If it is null, show notification
        // if the new one isn't.
        String oldNotificationText = getNotificationTitle(oldNotif);
        String newNotificationText = getNotificationTitle(newNotif);
        if (newNotificationText == null ? oldNotificationText != null : !newNotificationText
                .equals(oldNotificationText)) {
            return true;
        }

        // Last chance, check when the notifications were posted. If times
        // are equal, we shouldn't display the new notification.
        if (oldNotif.getNotification().when != newNotif.getNotification().when) {
            return true;
        }
        return false;
    }
    return true;
}
 
Example #4
Source File: Notification.java    From an2linuxclient with GNU General Public License v3.0 6 votes vote down vote up
@RequiresApi(Build.VERSION_CODES.KITKAT)
private void extractTitle(StatusBarNotification sbn, PackageManager pm) {
    Bundle extras = sbn.getNotification().extras;

    String contentTitle = "";
    CharSequence temp = extras.getCharSequence(android.app.Notification.EXTRA_TITLE);
    if (temp != null){
        contentTitle = temp.toString();
    }

    String appName = getAppName(pm, sbn.getPackageName());

    title = "";

    if (ns.forceTitle()){
        title = appName;
    } else {
        if (!contentTitle.equals("")){
            title = contentTitle;
        } else {
            title = appName;
        }
    }

    title = title.trim();
}
 
Example #5
Source File: DownloadNotificationService.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Returns whether or not there are any download notifications showing that aren't the summary
 * notification.
 * @param notificationIdToIgnore If not -1, the id of a notification to ignore and
 *                               assume is closing or about to be closed.
 * @return Whether or not there are valid download notifications currently visible.
 */
@TargetApi(Build.VERSION_CODES.M)
private static boolean hasDownloadNotifications(
        NotificationManager manager, int notificationIdToIgnore) {
    if (!useForegroundService()) return false;

    StatusBarNotification[] notifications = manager.getActiveNotifications();
    for (StatusBarNotification notification : notifications) {
        boolean isDownloadsGroup = TextUtils.equals(notification.getNotification().getGroup(),
                NotificationConstants.GROUP_DOWNLOADS);
        boolean isSummaryNotification =
                notification.getId() == NotificationConstants.NOTIFICATION_ID_DOWNLOAD_SUMMARY;
        boolean isIgnoredNotification =
                notificationIdToIgnore != -1 && notificationIdToIgnore == notification.getId();
        if (isDownloadsGroup && !isSummaryNotification && !isIgnoredNotification) return true;
    }

    return false;
}
 
Example #6
Source File: NotificationListener.java    From things-notification with Apache License 2.0 6 votes vote down vote up
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
    Log.d(TAG, "Notification received: "+sbn.getPackageName()+":"+sbn.getNotification().tickerText);

    if (sbn.getNotification().tickerText == null) {
        return;
    }

    WritableNativeMap params = new WritableNativeMap();
    params.putString("text", sbn.getNotification().tickerText.toString());

    String app = sbn.getPackageName();
    if (app.equals(NotificationModule.smsApp)) {
        params.putString("app", "sms");
    } else {
        params.putString("app", app);
    }

    NotificationModule.sendEvent("notificationReceived", params);
}
 
Example #7
Source File: NotificationService.java    From meter with Apache License 2.0 6 votes vote down vote up
/**
 * Called when notifications are removed
 */
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
    Intent intent = new  Intent(NOTIFICATION_UPDATE);
    intent.putExtra(NotificationKey.ACTION, NotificationAction.NOTIFICATION_REMOVED);
    intent.putExtra(NotificationKey.APPLICATION_PACKAGE_NAME,sbn.getPackageName());

    // List the notifications in a string array
    StatusBarNotification[] activeNotifications = NotificationService.this.getActiveNotifications();
    String packages[] = new String[activeNotifications.length];
    int i = 0;
    for (StatusBarNotification nf : activeNotifications) {
        packages[i++] = nf.getPackageName();
    }
    intent.putExtra(NotificationKey.APPLICATION_PACKAGES, packages);

    // Broadcast the intent
    sendBroadcast(intent);

    numNotifications = packages.length;
}
 
Example #8
Source File: NotificationListenerService.java    From BaldPhone with Apache License 2.0 6 votes vote down vote up
private void sendBroadcastToHomeScreenActivity() {
    try {
        final StatusBarNotification[] statusBarNotifications = getActiveNotifications();
        final ArrayList<String> packages = new ArrayList<>(statusBarNotifications.length);
        for (final StatusBarNotification statusBarNotification : statusBarNotifications) {
            packages.add(statusBarNotification.getPackageName());

        }
        final Intent intent = new Intent(HOME_SCREEN_ACTIVITY_BROADCAST)
                .putExtra("amount", statusBarNotifications.length)
                .putStringArrayListExtra("packages", packages);

        LocalBroadcastManager.getInstance(this)
                .sendBroadcast(intent);
    } catch (SecurityException e) {
        Log.e(TAG, e.getMessage());
        e.printStackTrace();
    }
}
 
Example #9
Source File: NotificationCountService.java    From Taskbar with Apache License 2.0 6 votes vote down vote up
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 #10
Source File: NotificationService.java    From zephyr with MIT License 6 votes vote down vote up
@Override
public void onNotificationRemoved(@Nullable StatusBarNotification sbn) {
    if (sbn == null) {
        logger.log(LogLevel.WARNING, LOG_TAG, "onNotificationRemoved: StatusBarNotification is null");
        return;
    }

    logger.log(LogLevel.VERBOSE, LOG_TAG, "onNotificationRemoved: [%s]\t%s", sbn.getId(), sbn.getPackageName());
    ZephyrExecutors.getDiskExecutor().execute(() -> {
        if (isValidNotification(sbn)) {
            DismissNotificationPayload dismissNotificationPayload = new DismissNotificationPayload();
            dismissNotificationPayload.packageName = sbn.getPackageName();
            dismissNotificationPayload.id = sbn.getId();

            logger.log(LogLevel.VERBOSE, LOG_TAG, "Dismissing notification: %s", sbn.getId());
            EventBus.getDefault().post(dismissNotificationPayload);
        }
    });
}
 
Example #11
Source File: NotificationService.java    From android-common with Apache License 2.0 6 votes vote down vote up
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
    if (Log.isPrint) {
        Log.i(TAG, sbn.toString());
        Notification notification = sbn.getNotification();
        Log.i(TAG, "tickerText : " + notification.tickerText);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Bundle bundle = notification.extras;
            for (String key : bundle.keySet()) {
                Log.i(TAG, key + ": " + bundle.get(key));
            }
        }
    }
    if (self != null && notificationListener != null) {
        notificationListener.onNotificationPosted(sbn);
    }
}
 
Example #12
Source File: SnoozeHelper.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
protected boolean cancel(int userId, String pkg, String tag, int id) {
    if (mSnoozedNotifications.containsKey(userId)) {
        ArrayMap<String, NotificationRecord> recordsForPkg =
                mSnoozedNotifications.get(userId).get(pkg);
        if (recordsForPkg != null) {
            final Set<Map.Entry<String, NotificationRecord>> records = recordsForPkg.entrySet();
            String key = null;
            for (Map.Entry<String, NotificationRecord> record : records) {
                final StatusBarNotification sbn = record.getValue().sbn;
                if (Objects.equals(sbn.getTag(), tag) && sbn.getId() == id) {
                    record.getValue().isCanceled = true;
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example #13
Source File: NotificationListener.java    From MiPushFramework with GNU General Public License v3.0 6 votes vote down vote up
private boolean checkAppSwitch(OnlineConfig onlineConfig, StatusBarNotification statusBarNotification) {
    boolean z = true;
    String stringValue = onlineConfig.getStringValue(ConfigKey.CollectionNotificationInfoAppSwitch.getValue(), "b");
    if (TextUtils.isEmpty(stringValue)) {
        return false;
    }
    List emptyList = Collections.emptyList();
    if (stringValue.length() > 1) {
        emptyList = Arrays.asList(stringValue.substring(1).split(";"));
    }
    String packageName = statusBarNotification.getPackageName();
    char charAt = stringValue.charAt(0);
    if (charAt != 'b') {
        return charAt == 'w' ? emptyList.contains(packageName) : false;
    } else {
        if (emptyList.contains(packageName)) {
            z = false;
        }
        return z;
    }
}
 
Example #14
Source File: NotificationPresenter.java    From AcDisplay with GNU General Public License v2.0 6 votes vote down vote up
void init(final @NonNull Context context,
          final @NonNull StatusBarNotification[] activeNotifications) {
    mHandler.post(new Runnable() {
        @SuppressLint("NewApi")
        @Override
        public void run() {
            clear(false);

            if (DEBUG) Log.d(TAG, "Initializing the notifications list...");
            // Initialize the notifications list through the proxy to
            // optimize the process. This is completely not useful on
            // pre-Lollipop devices due to lack of children notifications.
            List<NotificationPrTask> list = new ArrayList<>(activeNotifications.length);
            for (StatusBarNotification sbn : activeNotifications) {
                OpenNotification n = OpenNotification.newInstance(sbn);
                list.add(new NotificationPrTask(context, n, true /* post */, 0));
            }
            if (Device.hasLollipopApi()) mProxy.optimizePrTasks(list);
            mProxy.sendPrTasks(list);
            list.clear(); // This is probably not needed.
        }
    });
}
 
Example #15
Source File: NotificationReceiverService.java    From retrowatch with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    if(intent.getStringExtra("command").equals("clearall")){
    	NotificationReceiverService.this.cancelAllNotifications();
    }
    else if(intent.getStringExtra("command").equals("list")){
        for (StatusBarNotification sbn : NotificationReceiverService.this.getActiveNotifications()) {
            Intent i2 = new  Intent(Constants.NOTIFICATION_LISTENER);
            i2.putExtra(NOTIFICATION_KEY_CMD, NOTIFICATION_CMD_LIST);
            i2.putExtra(NOTIFICATION_KEY_ID, sbn.getId());
            i2.putExtra(NOTIFICATION_KEY_PACKAGE, sbn.getPackageName());
            i2.putExtra(NOTIFICATION_KEY_TEXT, sbn.getNotification().tickerText);
            sendBroadcast(i2);
        }
    }

}
 
Example #16
Source File: Notification.java    From Pi-Locker with GNU General Public License v2.0 6 votes vote down vote up
@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 #17
Source File: NotificationListener.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean handleMessage(Message message) {
    switch (message.what) {
        case MSG_NOTIFICATION_POSTED:
            if (sNotificationsChangedListener != null) {
                NotificationPostedMsg msg = (NotificationPostedMsg) message.obj;
                sNotificationsChangedListener.onNotificationPosted(msg.packageUserKey,
                        msg.notificationKey, msg.shouldBeFilteredOut);
            }
            break;
        case MSG_NOTIFICATION_REMOVED:
            if (sNotificationsChangedListener != null) {
                Pair<PackageUserKey, NotificationKeyData> pair
                        = (Pair<PackageUserKey, NotificationKeyData>) message.obj;
                sNotificationsChangedListener.onNotificationRemoved(pair.first, pair.second);
            }
            break;
        case MSG_NOTIFICATION_FULL_REFRESH:
            if (sNotificationsChangedListener != null) {
                sNotificationsChangedListener.onNotificationFullRefresh(
                        (List<StatusBarNotification>) message.obj);
            }
            break;
    }
    return true;
}
 
Example #18
Source File: NotificationListener.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onNotificationRemoved(final StatusBarNotification sbn) {
    super.onNotificationRemoved(sbn);
    Pair<PackageUserKey, NotificationKeyData> packageUserKeyAndNotificationKey
            = new Pair<>(PackageUserKey.fromNotification(sbn),
                    NotificationKeyData.fromNotification(sbn));
    mWorkerHandler.obtainMessage(MSG_NOTIFICATION_REMOVED, packageUserKeyAndNotificationKey)
            .sendToTarget();
}
 
Example #19
Source File: CallNotificationManager.java    From react-native-twilio-programmable-voice with MIT License 5 votes vote down vote up
public void removeIncomingCallNotification(ReactApplicationContext context,
                                           CallInvite callInvite,
                                           int notificationId) {
    Log.d(TAG, "removeIncomingCallNotification");
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
        if (callInvite != null && callInvite.getState() == CallInvite.State.PENDING) {
            /*
             * If the incoming call message was cancelled then remove the notification by matching
             * it with the call sid from the list of notifications in the notification drawer.
             */
            StatusBarNotification[] activeNotifications = notificationManager.getActiveNotifications();
            for (StatusBarNotification statusBarNotification : activeNotifications) {
                Notification notification = statusBarNotification.getNotification();
                String notificationType = notification.extras.getString(NOTIFICATION_TYPE);
                if (callInvite.getCallSid().equals(notification.extras.getString(CALL_SID_KEY)) &&
                        notificationType != null && notificationType.equals(ACTION_INCOMING_CALL)) {
                    notificationManager.cancel(notification.extras.getInt(INCOMING_CALL_NOTIFICATION_ID));
                }
            }
        } else if (notificationId != 0) {
            notificationManager.cancel(notificationId);
        }
    } else {
        if (notificationId != 0) {
            notificationManager.cancel(notificationId);
        } else if (callInvite != null) {
            String notificationKey = INCOMING_NOTIFICATION_PREFIX+callInvite.getCallSid();
            if (TwilioVoiceModule.callNotificationMap.containsKey(notificationKey)) {
                notificationId = TwilioVoiceModule.callNotificationMap.get(notificationKey);
                notificationManager.cancel(notificationId);
                TwilioVoiceModule.callNotificationMap.remove(notificationKey);
            }
        }
    }
}
 
Example #20
Source File: NotificationListenerLollipop.java    From HeadsUp with GNU General Public License v2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@Override
public void onListenerConnected(@NonNull NotificationListenerService service) {
    StatusBarNotification[] an = service.getActiveNotifications();
    if (an == null) return;
    NotificationPresenter np = NotificationPresenter.getInstance();
    np.init(service, an);
}
 
Example #21
Source File: NotificationPeek.java    From NotificationPeekPort with Apache License 2.0 5 votes vote down vote up
private boolean isNotificationActive(StatusBarNotification n) {

        for (StatusBarNotification notification : mNotificationHub.getNotifications()) {
            if (NotificationHelper.getContentDescription(n)
                    .equals(NotificationHelper.getContentDescription(notification))) {
                return true;
            }
        }

        return false;
    }
 
Example #22
Source File: Compatibility.java    From linphone-android with GNU General Public License v3.0 5 votes vote down vote up
public static StatusBarNotification[] getActiveNotifications(NotificationManager manager) {
    if (Version.sdkAboveOrEqual(Version.API23_MARSHMALLOW_60)) {
        return ApiTwentyThreePlus.getActiveNotifications(manager);
    }

    return new StatusBarNotification[0];
}
 
Example #23
Source File: GroupHelper.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Un-autogroups notifications that are now grouped by the app.
 */
private void maybeUngroup(StatusBarNotification sbn, boolean notificationGone, int userId) {
    List<String> notificationsToUnAutogroup = new ArrayList<>();
    boolean removeSummary = false;
    synchronized (mUngroupedNotifications) {
        Map<String, LinkedHashSet<String>> ungroupedNotificationsByUser
                = mUngroupedNotifications.get(sbn.getUserId());
        if (ungroupedNotificationsByUser == null || ungroupedNotificationsByUser.size() == 0) {
            return;
        }
        LinkedHashSet<String> notificationsForPackage
                = ungroupedNotificationsByUser.get(sbn.getPackageName());
        if (notificationsForPackage == null || notificationsForPackage.size() == 0) {
            return;
        }
        if (notificationsForPackage.remove(sbn.getKey())) {
            if (!notificationGone) {
                // Add the current notification to the ungrouping list if it still exists.
                notificationsToUnAutogroup.add(sbn.getKey());
            }
        }
        // If the status change of this notification has brought the number of loose
        // notifications to zero, remove the summary and un-autogroup.
        if (notificationsForPackage.size() == 0) {
            ungroupedNotificationsByUser.remove(sbn.getPackageName());
            removeSummary = true;
        }
    }
    if (removeSummary) {
        adjustAutogroupingSummary(userId, sbn.getPackageName(), null, false);
    }
    if (notificationsToUnAutogroup.size() > 0) {
        adjustNotificationBundling(notificationsToUnAutogroup, false);
    }
}
 
Example #24
Source File: NevoDecoratorService.java    From sdk with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve historic notifications posted with the given key (including the incoming one without decoration at the last).
 * The number of notifications kept in archive is undefined.
 *
 * Decorator permission restriction applies.
 */
protected final List<StatusBarNotification> getArchivedNotifications(final String key, final int limit) {
	try {
		return mController.getNotifications(mWrapper, TYPE_ARCHIVED, singletonList(key), limit, null);
	} catch (final RemoteException e) {
		Log.w(TAG, "Error retrieving archived notifications: " + key, e);
		return Collections.emptyList();
	}
}
 
Example #25
Source File: NotificationListenerJellyBeanMR2.java    From AcDisplay with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private boolean postActiveNotifications(@NonNull NotificationListenerService service) {
    StatusBarNotification[] an = service.getActiveNotifications();
    if (an == null) return false;
    NotificationPresenter np = NotificationPresenter.getInstance();
    np.init(service, an);
    return mInitialized = true;
}
 
Example #26
Source File: NotificationListenerJellyBeanMR2.java    From AcDisplay with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onNotificationPosted(@NonNull NotificationListenerService service,
                                 @NonNull StatusBarNotification sbn) {
    if (mInitialized || !postActiveNotifications(service)) {
        Context context = service.getApplicationContext();
        NotificationPresenter np = NotificationPresenter.getInstance();
        np.postNotificationFromMain(context, OpenNotification.newInstance(sbn), 0);
    }
}
 
Example #27
Source File: OpenNotification.java    From HeadsUp with GNU General Public License v2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@NonNull
public static OpenNotification newInstance(@NonNull StatusBarNotification sbn) {
    Notification n = sbn.getNotification();
    if (Device.hasLollipopApi()) {
        return new OpenNotificationLollipop(sbn, n);
    } else if (Device.hasKitKatWatchApi()) {
        return new OpenNotificationKitKatWatch(sbn, n);
    }

    return new OpenNotificationJellyBeanMR2(sbn, n);
}
 
Example #28
Source File: NotificationListener.java    From android-notification-log with MIT License 5 votes vote down vote up
public static StatusBarNotification[] getAllActiveNotifications() {
	if(instance != null) {
		try {
			return instance.getActiveNotifications();
		} catch (Exception e) {
			if(Const.DEBUG) e.printStackTrace();
		}
	}
	return null;
}
 
Example #29
Source File: OpenNotification.java    From AcDisplay with GNU General Public License v2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@NonNull
static OpenNotification newInstance(@NonNull StatusBarNotification sbn) {
    Notification n = sbn.getNotification();
    if (Device.hasLollipopApi()) {
        return new OpenNotificationLollipop(sbn, n);
    } else if (Device.hasKitKatWatchApi()) {
        return new OpenNotificationKitKatWatch(sbn, n);
    }

    return new OpenNotificationJellyBeanMR2(sbn, n);
}
 
Example #30
Source File: NotificationListener.java    From Mi-Band with GNU General Public License v2.0 5 votes vote down vote up
private void handleNotification(StatusBarNotification sbn) {
    //only if we have a valid notification, we need to post it to Mi Band Service
    App app = AppsSQLite.getInstance(NotificationListener.this).getApp(sbn.getPackageName());

    //Log.i(TAG, "handleNotification: " + app.getName());

    miBand.notifyBand(app.getColor());

    /*
    //HashMap<String, Integer> params = new HashMap<String, Integer>();

    //params.put(NotificationConstants.KEY_COLOR, app.getColor());

    //MiBand.sendAction(MiBandWrapper.ACTION_NOTIFY, params);

    int vibrate_times = -1;
    int flash_time = -1;
    int pause_time = -1;

    if (b.containsKey(NotificationConstants.KEY_TIMES))
        vibrate_times = b.getInt(NotificationConstants.KEY_TIMES, 3);

    if (b.containsKey(NotificationConstants.KEY_ON_TIME))
        flash_time = b.getInt(NotificationConstants.KEY_ON_TIME, 250);

    if (b.containsKey(NotificationConstants.KEY_PAUSE_TIME))
        pause_time = b.getInt(NotificationConstants.KEY_PAUSE_TIME, 500);

    int color = b.getInt(NotificationConstants.KEY_COLOR, 255);

    if (vibrate_times == -1 || flash_time == -1 || pause_time == -1)
        miBand.notifyBand(color);
    else
        miBand.notifyBand(vibrate_times, flash_time, pause_time, color);
    */

    MiBandWrapper.getInstance(NotificationListener.this).sendAction(MiBandWrapper.ACTION_REQUEST_CONNECTION);
}