mobile/android/base/NotificationService.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
     2  * This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 package org.mozilla.gecko;
     8 import android.app.Notification;
     9 import android.app.Service;
    10 import android.content.Intent;
    11 import android.os.Binder;
    12 import android.os.IBinder;
    14 public class NotificationService extends Service {
    15     private final IBinder mBinder = new NotificationBinder();
    16     private NotificationHandler mHandler;
    18     @Override
    19     public void onCreate() {
    20         // This has to be initialized in onCreate in order to ensure that the NotificationHandler can
    21         // access the NotificationManager service.
    22         mHandler = new NotificationHandler(this) {
    23             @Override
    24             protected void setForegroundNotification(int id, Notification notification) {
    25                 super.setForegroundNotification(id, notification);
    27                 if (notification == null) {
    28                     stopForeground(true);
    29                 } else {
    30                     startForeground(id, notification);
    31                 }
    32             }
    33         };
    34     }
    36     public class NotificationBinder extends Binder {
    37         NotificationService getService() {
    38             // Return this instance of NotificationService so clients can call public methods
    39             return NotificationService.this;
    40         }
    41     }
    43     @Override
    44     public IBinder onBind(Intent intent) {
    45         return mBinder;
    46     }
    48     public NotificationHandler getNotificationHandler() {
    49         return mHandler;
    50     }
    51 }

mercurial