コード例 #1
0
  @Override
  public void onNotificationPosted(StatusBarNotification sbn) {

    Log.i(TAG, sbn.getPackageName() + " Notification received:" + sbn.getNotification().tickerText);

    Notification postedNotification = sbn.getNotification();

    String packageName = sbn.getPackageName();

    if (postedNotification.tickerText == null
        || sbn.isOngoing()
        || !sbn.isClearable()
        || isInBlackList(packageName)) {
      return;
    }

    mNotificationHub.addNotification(sbn);

    mNotificationHub.setCurrentNotification(sbn);

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

    // Retrieve user specified peek timeout.
    int peekTimeoutMultiplier =
        Integer.parseInt(preferences.getString(PreferenceKeys.PREF_PEEK_TIMEOUT, "1"));

    // Does user select always listening?
    boolean alwaysListening = preferences.getBoolean(PreferenceKeys.PREF_ALWAYS_LISTENING, false);

    mNotificationPeek.showNotification(sbn, false, peekTimeoutMultiplier, alwaysListening);
  }
コード例 #2
0
 @Override
 public void onNotificationRemoved(StatusBarNotification sbn) {
   mNotificationHub.removeNotification(sbn);
 }
コード例 #3
0
 @Override
 public void onCreate() {
   super.onCreate();
   mNotificationHub = NotificationHub.getInstance();
   mNotificationPeek = new NotificationPeek(mNotificationHub, this);
 }