Android Open Source - qcn Notification Listener






From Project

Back to project page qcn.

License

The source code is released under:

GNU General Public License

If you think the Android project qcn listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package zsoltmester.qcn.quickcircle.notifications;
//www.  j av a2  s. c  o  m
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;

import zsoltmester.qcn.tools.Logger;

public class NotificationListener extends NotificationListenerService {

  private final Logger logger = Logger.createWithLogTag(NotificationListener.class.getSimpleName());
  public static final String ACTION_NOTIFICATION_LISTENER = "zsoltmester.qcn.notifications.NOTIFICATION_LISTENER";
  private IBinder helperBinder = new HelperBinder();
  private Callback callbackListener;

  @Override
  public IBinder onBind(Intent intent) {
    logger.log("onBind");
    return intent.getAction().equals(ACTION_NOTIFICATION_LISTENER) ? helperBinder : super.onBind(intent);
  }

  @Override
  public void onNotificationRemoved(StatusBarNotification statusBarNotification, RankingMap rankingMap) {
    logger.log("onNotificationRemoved");
    if (callbackListener != null) {
      callbackListener.onNotificationRemoved(statusBarNotification, rankingMap.getOrderedKeys());
    }
  }

  @Override
  public void onNotificationPosted(StatusBarNotification statusBarNotification, RankingMap rankingMap) {
    logger.log("onNotificationPosted");
    if (callbackListener != null) {
      callbackListener.onNotificationPosted(statusBarNotification, rankingMap.getOrderedKeys());
    }
  }

  @Override
  public void onNotificationRankingUpdate(RankingMap rankingMap) {
    logger.log("onNotificationRankingUpdate");
    if (callbackListener != null) {
      callbackListener.onNotificationRankingUpdate(rankingMap.getOrderedKeys());
    }
  }

  public void setCallbackListener(Callback callbackListener) {
    this.callbackListener = callbackListener;
  }

  public interface Callback {
    void onNotificationPosted(StatusBarNotification statusBarNotification, String[] orderedRankingMapKeys);

    void onNotificationRemoved(StatusBarNotification statusBarNotification, String[] orderedRankingMapKeys);

    void onNotificationRankingUpdate(String[] orderedRankingMapKeys);
  }

  /**
   * {@link Binder} which helps to get the {@link NotificationListener} service.
   */
  public class HelperBinder extends Binder {

    /**
     * @return The running {@link NotificationListener} service instance.
     */
    public NotificationListener getRunningNotificationListenerService() {
      return NotificationListener.this;
    }
  }
}




Java Source Code List

zsoltmester.qcn.desktop.ContactFragment.java
zsoltmester.qcn.desktop.DesktopActivity.java
zsoltmester.qcn.quickcircle.CoverEventReceiver.java
zsoltmester.qcn.quickcircle.QuickCircleBaseActivity.java
zsoltmester.qcn.quickcircle.notifications.NotificationActivity.java
zsoltmester.qcn.quickcircle.notifications.NotificationAdapter.java
zsoltmester.qcn.quickcircle.notifications.NotificationHelper.java
zsoltmester.qcn.quickcircle.notifications.NotificationListener.java
zsoltmester.qcn.tools.Logger.java
zsoltmester.qcn.ui.SimpleOnGestureListenerWithDoubleTapSupport.java