--- a/mobile/android/base/java/org/mozilla/gecko/NotificationHandler.java
+++ b/mobile/android/base/java/org/mozilla/gecko/NotificationHandler.java
@@ -55,16 +55,17 @@ public class NotificationHandler {
String aAlertText, PendingIntent contentIntent, String origin) {
// Remove the old notification with the same ID, if any
remove(notificationID);
// TODO: Service intent to clear pref on reopen.
Intent prefIntent = new Intent(Intent.ACTION_VIEW);
prefIntent.setClassName(AppConstants.ANDROID_PACKAGE_NAME, AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS);
PendingIntent buttonIntent = PendingIntent.getActivity(mContext, 0, prefIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent testIntent = PendingIntent.getService(mContext, 0, prefIntent, PendingIntent.FLAG_UPDATE_CURRENT);
final NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext)
.setContentTitle(aAlertTitle)
.setContentText(aAlertText)
.setSmallIcon(R.drawable.ic_status_logo)
.setContentIntent(contentIntent)
.setAutoCancel(true)
.setStyle(new NotificationCompat.InboxStyle()
--- a/mobile/android/base/java/org/mozilla/gecko/NotificationService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/NotificationService.java
@@ -1,25 +1,31 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko;
+import android.app.IntentService;
import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
-public class NotificationService extends Service {
+public class NotificationService extends IntentService {
+ private static final String LOGTAG = "GeckoNotifactionService";
private final IBinder mBinder = new NotificationBinder();
private NotificationHandler mHandler;
+ public NotificationService(){
+ super(LOGTAG);
+ }
+
@Override
public void onCreate() {
// This has to be initialized in onCreate in order to ensure that the NotificationHandler can
// access the NotificationManager service.
mHandler = new NotificationHandler(this) {
@Override
protected void setForegroundNotification(int id, Notification notification) {
super.setForegroundNotification(id, notification);
@@ -28,16 +34,22 @@ public class NotificationService extends
stopForeground(true);
} else {
startForeground(id, notification);
}
}
};
}
+ @Override
+ protected void onHandleIntent(final Intent intent) {
+ // If Firefox is running, process intent immediately and block notifications from the site.
+ // If Firefox is not running, save a JSON file and update a pref.
+ }
+
public class NotificationBinder extends Binder {
NotificationService getService() {
// Return this instance of NotificationService so clients can call public methods
return NotificationService.this;
}
}
@Override