summaryrefslogtreecommitdiff
path: root/navit/android/src/org/navitproject/navit/Navit.java
diff options
context:
space:
mode:
Diffstat (limited to 'navit/android/src/org/navitproject/navit/Navit.java')
-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();
}