package org.blitzortung.android.app.controller;


import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import org.blitzortung.android.app.Main;
import org.blitzortung.android.app.R;

public class NotificationHandler {

    private final NotificationManager notificationService;
    private final Context context;

    public NotificationHandler(Context context) {
        notificationService = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        this.context = context;

    }

    public void sendNotification(String notificationText) {
        if (notificationService != null) {
            Notification notification = new Notification(R.drawable.icon, notificationText, System.currentTimeMillis());
            PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, Main.class), 0);
            notification.setLatestEventInfo(context, context.getResources().getText(R.string.app_name), notificationText, contentIntent);

            notificationService.notify(R.id.alarm_notification_id, notification);
        }
    }

    public void clearNotification() {
        if (notificationService != null) {
            notificationService.cancel(R.id.alarm_notification_id);
        }
    }
}

@@ -146,24 +146,61 @@
 dingIntent;%0A
+import android.app.TaskStackBuilder;%0A
 import andro
@@ -647,25 +647,24 @@
  = context;%0A
-%0A
     %7D%0A%0A    p
@@ -777,234 +777,338 @@
     
-Notification notification = new Notification(R.drawable.icon, notificationText, System.currentTimeMillis());%0A            PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, Main.class), 0);%0A
+Intent intent = new Intent(context, Main.class);%0A            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP %7C Intent.FLAG_ACTIVITY_SINGLE_TOP);%0A            PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);%0A%0A            Notification.Builder notificationBuilder =%0A      
     
@@ -1107,33 +1107,39 @@
                 
-n
+  new N
 otification.setL
@@ -1138,105 +1138,288 @@
 ion.
-setLatestEventInfo(context, context.getResources().getText(R.string.app_name), notificationText, 
+Builder(context)%0A                            .setSmallIcon(R.drawable.icon)%0A                            .setContentTitle(context.getResources().getText(R.string.app_name))%0A                            .setContentText(notificationText)%0A                            .setContentIntent(
 cont
@@ -1510,16 +1510,41 @@
 fication
+Builder.getNotification()
 );%0A     

Use NotificationBuilder instead of the Notification to create a new Notification