summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkoan <jkoan@users.noreply.github.com>2017-11-23 19:23:05 +0100
committerPierre GRANDIN <pgrandin@users.noreply.github.com>2017-11-23 10:23:05 -0800
commit41f50278bea098ea98f5d77c94a706517ddc7798 (patch)
treed504221344625a26d4153113b561c47efbf9df52
parent445697c7f66dadf79abce19c224da404d647ee30 (diff)
downloadnavit-41f50278bea098ea98f5d77c94a706517ddc7798.tar.gz
fix:android:reworked notification system for sdk 23 (#374)
* fix:android:Made main notification working again. It now uses NotificationCompat from android support to support android from api 4 and up. * fix:android:Made main notification working again. It now uses NotificationCompat from android support to support android from api 4 and up.
-rw-r--r--navit/android/src/org/navitproject/navit/Navit.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/navit/android/src/org/navitproject/navit/Navit.java b/navit/android/src/org/navitproject/navit/Navit.java
index d3b970e98..7505e7ff7 100644
--- a/navit/android/src/org/navitproject/navit/Navit.java
+++ b/navit/android/src/org/navitproject/navit/Navit.java
@@ -80,6 +80,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
+import android.support.v4.app.NotificationCompat;
public class Navit extends Activity
@@ -119,6 +120,7 @@ public class Navit extends Activity
public static final String NAVIT_PREFS = "NavitPrefs";
Boolean isFullscreen = false;
private static final int MY_PERMISSIONS_REQUEST_ALL = 101;
+ public static NotificationManager nm;
/**
@@ -292,13 +294,17 @@ public class Navit extends Activity
// NOTIFICATION
// Setup the status bar notification
// This notification is removed in the exit() function
- NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // Grab a handle to the NotificationManager
- Notification NavitNotification = new Notification(R.drawable.ic_notify, getString(R.string.notification_ticker), System.currentTimeMillis()); // Create a new notification, with the text string to show when the notification first appears
+ nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // Grab a handle to the NotificationManager
PendingIntent appIntent = PendingIntent.getActivity(getApplicationContext(), 0, getIntent(), 0);
- //FIXME : needs a fix for sdk 23
- //NavitNotification.setLatestEventInfo(getApplicationContext(), "Navit", getString(R.string.notification_event_default), appIntent); // Set the text in the notification
- //NavitNotification.flags|=Notification.FLAG_ONGOING_EVENT; // Ensure that the notification appears in Ongoing
- nm.notify(R.string.app_name, NavitNotification); // Set the notification
+
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
+ builder.setContentIntent(appIntent);
+ builder.setAutoCancel(false).setOngoing(true);
+ builder.setContentTitle(getString(R.string.app_name));
+ builder.setContentText(getString(R.string.notification_event_default));
+ builder.setSmallIcon(R.drawable.ic_notify);
+ Notification NavitNotification = builder.build();
+ nm.notify(R.string.app_name, NavitNotification);// Show the notification
// Status and navigation bar sizes
// These are platform defaults and do not change with rotation, but we have to figure out which ones apply
@@ -906,8 +912,7 @@ public class Navit extends Activity
public void exit()
{
-// NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
-// nm.cancel(R.string.app_name);
+ nm.cancelAll();
NavitVehicle.removeListener();
NavitDestroy();
}