Example usage for android.app Notification PRIORITY_DEFAULT

List of usage examples for android.app Notification PRIORITY_DEFAULT

Introduction

In this page you can find the example usage for android.app Notification PRIORITY_DEFAULT.

Prototype

int PRIORITY_DEFAULT

To view the source code for android.app Notification PRIORITY_DEFAULT.

Click Source Link

Document

Default notification #priority .

Usage

From source file:com.zion.music.NotificationHelper.java

/**
 * Call this to build the {@link Notification}.
 *//*from w w  w . j ava 2s.c o  m*/
public void buildNotification(final String artistName, final String trackName, final int artistId,
        final Bitmap albumArt, final boolean isPlaying) {
    // Default notification layout
    this.notificationTemplate = new RemoteViews(this.service.getPackageName(),
            R.layout.notification_mediaplayer);

    // Set up the content view
    this.initCollapsedLayout(trackName, artistName, albumArt);

    // Notification Builder
    this.notification = new NotificationCompat.Builder(this.service)
            .setSmallIcon(R.drawable.ic_stat_notify_app_icon).setContentIntent(this.getPendingIntent(artistId))
            .setPriority(Notification.PRIORITY_DEFAULT).setContent(this.notificationTemplate)
            .setAutoCancel(true).build();

    // Control playback from the notification
    this.initPlaybackActions(isPlaying);
    if (16 <= Build.VERSION.SDK_INT) {
        // Expanded notification style
        this.expandedView = new RemoteViews(this.service.getPackageName(),
                R.layout.notification_template_expanded);
        this.notification.bigContentView = this.expandedView;

        // Control playback from the expanded notification
        this.initExpandedPlaybackActions(isPlaying);

        // Set up the expanded content view
        this.initExpandedLayout(trackName, artistName, albumArt);
    }
    //      this.service.stopForeground(false);
    this.service.startForeground(NotificationHelper.NOTIFICATION_ID, this.notification);
}

From source file:es.usc.citius.servando.calendula.activities.PickupNotification.java

/**
 * Shows the notification, or updates a previously shown notification of
 * this type, with the given parameters.
 * <p/>// w  ww.ja v  a  2s  .c  o  m
 * TODO: Customize this method's arguments to present relevant content in
 * the notification.
 * <p/>
 * TODO: Customize the contents of this method to tweak the behavior and
 * presentation of message notifications. Make
 * sure to follow the
 * <a href="https://developer.android.com/design/patterns/notifications.html">
 * Notification design guidelines</a> when doing so.
 *
 * @see #cancel(android.content.Context)
 */
public static void notify(final Context context, final String title, final String description, Intent intent) {

    final Resources res = context.getResources();

    // if notifications are disabled, exit
    // boolean notifications = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("alarm_notifications", true);
    //        if (!notifications) {
    //            return;
    //        }

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    String delayMinutesStr = prefs.getString("alarm_repeat_frequency", "15");

    // This image is used as the notification's large icon (thumbnail).
    final Bitmap picture = BitmapFactory.decodeResource(res, R.drawable.ic_event_available_black_48dp);
    //final Bitmap largeIcon = BitmapFactory.decodeResource(res, R.drawable.ic_pill_48dp);

    NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
    style.setBigContentTitle(description);
    //style.setSummaryText("Notification Summary");

    final String ticker = title;
    final String text = title;

    PendingIntent defaultIntent = PendingIntent.getActivity(context, 0, intent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)

            // Set appropriate defaults for the notification light, sound,
            // and vibration.
            .setDefaults(Notification.DEFAULT_ALL).setSmallIcon(R.drawable.ic_event_available_white_48dp)
            .setLargeIcon(picture).setContentTitle(title).setContentText(description).setAutoCancel(true)
            .setPriority(NotificationCompat.PRIORITY_DEFAULT).setLargeIcon(picture).setTicker(ticker)
            .setContentIntent(defaultIntent).setStyle(style).setPriority(Notification.PRIORITY_DEFAULT)
            .setVibrate(new long[] { 1000, 200, 500, 200, 100, 200, 1000 })
            //.setSound(ringtoneUri != null ? ringtoneUri : Settings.System.DEFAULT_NOTIFICATION_URI)
            .setAutoCancel(true);

    Notification n = builder.build();
    n.defaults = 0;
    n.ledARGB = 0x00ffa500;
    n.ledOnMS = 1000;
    n.ledOffMS = 2000;
    notify(context, n);
}

From source file:com.example.android.lnotifications.HeadsUpNotificationFragment.java

/**
 * Creates a new notification depending on the argument.
 *
 * @param makeHeadsUpNotification A boolean value to indicating whether a notification will be
 *                                created as a heads-up notification or not.
 *                                <ul>
 *                                <li>true : Creates a heads-up notification.</li>
 *                                <li>false : Creates a non-heads-up notification.</li>
 *                                </ul>
 *
 * @return A Notification instance./*from   w  ww  .  java  2s.co m*/
 */
private Notification createNotification(boolean makeHeadsUpNotification) {
    Notification.Builder notificationBuilder = new Notification.Builder(getActivity())
            .setSmallIcon(R.drawable.ic_launcher_notification).setPriority(Notification.PRIORITY_DEFAULT)
            .setCategory(Notification.CATEGORY_MESSAGE).setContentTitle("Sample Notification")
            .setContentText("This is a normal notification.");
    if (makeHeadsUpNotification) {
        Intent push = new Intent();
        push.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        push.setClass(getActivity(), LNotificationActivity.class);

        PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(getActivity(), 0, push,
                PendingIntent.FLAG_CANCEL_CURRENT);
        notificationBuilder.setContentText("Heads-Up Notification on Android L or above.")
                .setFullScreenIntent(fullScreenPendingIntent, true);
    }
    return notificationBuilder.build();
}

From source file:com.android.madpausa.cardnotificationviewer.ConcreteNotificationListenerService.java

public void handlePostedNotification(StatusBarNotification sbn) {
    //should be removed if already existing, in order to put it back in top position
    removeInternalNotification(sbn);/*from w  ww . j a  v a2 s  . co  m*/
    NotificationFilter priorityFilter = ((NotificationFilter) baseNotificationFilter.clone())
            .setMinPriority(Notification.PRIORITY_DEFAULT);
    //if the notification has to be shown, is putted in the primary map
    if (!alwaysArchiveFilter.matchFilter(sbn, notificationGroups, true)
            && priorityFilter.matchFilter(sbn, notificationGroups, true))
        notificationMap.put(NotificationFilter.getNotificationKey(sbn), sbn);
    else {
        //otherwise, it goes directly in the archived ones
        archivedNotificationMap.put(NotificationFilter.getNotificationKey(sbn), sbn);
    }

    //adding it to the group structure
    notificationGroups.addGroupMember(sbn);

    //if the notification are more than the threshold, archive older ones
    if (notificationMap.size() > Integer
            .parseInt(sp.getString(SettingsActivityFragment.NOTIFICATION_THRESHOLD, "-1")))
        archiveNotifications();

    //sending notification to binded clients
    Intent intent = new Intent(ADD_NOTIFICATION_ACTION);
    intent.putExtra(NOTIFICATION_EXTRA, sbn);
    LocalBroadcastManager.getInstance(this).sendBroadcast(intent);

    //sending notification only at the end, always, as it would be canceled, at most
    handleServiceNotification();
}

From source file:net.networksaremadeofstring.rhybudd.Notifications.java

public static void SendGCMNotification(ZenossEvent Event, Context context) {
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);

    Time now = new Time();
    now.setToNow();/*ww w  .j a va 2s. c  o m*/

    //We don't need to overwhelm the user with their notification sound / vibrator
    if ((now.toMillis(true) - PreferenceManager.getDefaultSharedPreferences(context).getLong("lastCheck",
            now.toMillis(true))) < 3000) {
        //Log.e("SendGCMNotification", "Not publishing a notification due to stampede control");
        return;
    }

    Intent notificationIntent = new Intent(context, ViewZenossEventsListActivity.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    notificationIntent.putExtra("forceRefresh", true);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

    Uri soundURI = null;
    try {
        if (settings.getBoolean("notificationSound", true)) {
            if (settings.getString("notificationSoundChoice", "").equals("")) {
                soundURI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            } else {
                try {
                    soundURI = Uri.parse(settings.getString("notificationSoundChoice", ""));
                } catch (Exception e) {
                    soundURI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                }
            }
        } else {
            soundURI = null;
        }
    } catch (Exception e) {

    }

    String notifTitle = "New Events Received";
    int notifPriority = Notification.PRIORITY_DEFAULT;
    //int AlertType = NOTIFICATION_GCM_GENERIC;

    try {
        if (Event.getSeverity().equals("5")) {
            notifTitle = context.getString(R.string.CriticalNotificationTitle);
            notifPriority = Notification.PRIORITY_MAX;
            //AlertType = NOTIFICATION_GCM_CRITICAL;
        } else if (Event.getSeverity().equals("4")) {
            notifTitle = context.getString(R.string.ErrorNotificationTitle);
            notifPriority = Notification.PRIORITY_HIGH;
            //AlertType = NOTIFICATION_GCM_ERROR;
        } else if (Event.getSeverity().equals("3")) {
            notifTitle = context.getString(R.string.WarnNotificationTitle);
            notifPriority = Notification.PRIORITY_DEFAULT;
            //AlertType = NOTIFICATION_GCM_WARNING;
        } else if (Event.getSeverity().equals("2")) {
            notifTitle = context.getString(R.string.InfoNotificationTitle);
            notifPriority = Notification.PRIORITY_LOW;
            //AlertType = NOTIFICATION_GCM_INFO;
        } else if (Event.getSeverity().equals("1")) {
            notifTitle = context.getString(R.string.DebugNotificationTitle);
            notifPriority = Notification.PRIORITY_MIN;
            //AlertType = NOTIFICATION_GCM_DEBUG;
        }
    } catch (Exception e) {

    }

    long[] vibrate = { 0, 100, 200, 300 };

    try {
        AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);

        //Log.e("audio.getRingerMode()",Integer.toString(audio.getRingerMode()));
        switch (audio.getRingerMode()) {
        case AudioManager.RINGER_MODE_SILENT:
            //Do nothing to fix GitHub issue #13
            //Log.e("AudioManager","Doing nothing because we are silent");
            vibrate = new long[] { 0, 0 };
            break;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    Intent broadcastMassAck = new Intent();
    broadcastMassAck.setAction(MassAcknowledgeReceiver.BROADCAST_ACTION);
    PendingIntent pBroadcastMassAck = PendingIntent.getBroadcast(context, 0, broadcastMassAck, 0);

    if (Build.VERSION.SDK_INT >= 16) {
        Notification noti = new Notification.BigTextStyle(new Notification.Builder(context)
                .setContentTitle(notifTitle).setPriority(notifPriority).setAutoCancel(true).setSound(soundURI)
                .setVibrate(vibrate).setContentText(Event.getDevice()).setContentIntent(contentIntent)
                .addAction(R.drawable.ic_action_resolve_all, "Acknowledge all Events", pBroadcastMassAck)
                .setSmallIcon(R.drawable.ic_stat_alert)).bigText(
                        Event.getSummary() + "\r\n" + Event.getComponentText() + "\r\n" + Event.geteventClass())
                        .build();

        if (settings.getBoolean("notificationSoundInsistent", false))
            noti.flags |= Notification.FLAG_INSISTENT;

        noti.tickerText = notifTitle;

        NotificationManager mNM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        mNM.notify(NOTIFICATION_GCM_GENERIC, noti);
    } else {
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
                .setSmallIcon(R.drawable.ic_stat_alert).setContentTitle(notifTitle)
                .setContentText(Event.getDevice() + ": " + Event.getSummary()).setContentIntent(contentIntent)
                .setSound(soundURI).setVibrate(vibrate)
                .addAction(R.drawable.ic_action_resolve_all, "Acknowledge all Events", pBroadcastMassAck)
                .setAutoCancel(true).setPriority(notifPriority);

        NotificationManager mNM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        mNM.notify(NOTIFICATION_GCM_GENERIC, mBuilder.build());
    }
}

From source file:org.videolan.vlc.RecommendationsService.java

private boolean doRecommendations() {
    mNotificationManager.cancelAll();//ww  w.  j a  v  a 2  s . c om
    int id = 0;
    ArrayList<MediaWrapper> videoList = MediaLibrary.getInstance().getVideoItems();
    if (Util.isListEmpty(videoList))
        return false;
    Bitmap pic;
    Collections.shuffle(videoList);
    for (MediaWrapper mediaWrapper : videoList) {
        pic = mMediaDatabase.getPicture(mediaWrapper.getUri());
        if (pic != null && pic.getByteCount() > 4 && mediaWrapper.getTime() == 0) {
            buildRecommendation(mediaWrapper, ++id, Notification.PRIORITY_DEFAULT);
        }
        if (id == MAX_RECOMMENDATIONS)
            break;
    }
    return true;
}

From source file:de.baumann.hhsmoodle.popup.Popup_todo_restart.java

private void setTodoList() {

    NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nMgr.cancelAll();//from w w w.  java  2s . c o  m

    Schedule_helper.setAlarm(Popup_todo_restart.this);

    Intent serviceIntent = new Intent(Popup_todo_restart.this, class_AlarmService.class);
    startService(serviceIntent);

    //display data
    final int layoutstyle = R.layout.list_item_notes;
    int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes };
    String[] column = new String[] { "todo_title", "todo_content", "todo_creation" };
    final Cursor row = db.fetchAllData(Popup_todo_restart.this);
    SimpleCursorAdapter adapter = new SimpleCursorAdapter(Popup_todo_restart.this, layoutstyle, row, column,
            xml_id, 0) {
        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title"));
            final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content"));
            final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment"));

            View v = super.getView(position, convertView, parent);
            ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes);

            switch (todo_attachment) {
            case "true":
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.alert_circle);
                break;
            default:
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.alert_circle_red);

                int n = Integer.valueOf(_id);

                android.content.Intent iMain = new android.content.Intent();
                iMain.setAction("shortcutToDo");
                iMain.setClassName(Popup_todo_restart.this, "de.baumann.hhsmoodle.activities.Activity_splash");
                PendingIntent piMain = PendingIntent.getActivity(Popup_todo_restart.this, n, iMain, 0);

                NotificationCompat.Builder builderSummary = new NotificationCompat.Builder(
                        Popup_todo_restart.this).setSmallIcon(R.drawable.school)
                                .setColor(ContextCompat.getColor(Popup_todo_restart.this, R.color.colorPrimary))
                                .setGroup("HHS_Moodle").setGroupSummary(true).setContentIntent(piMain);

                Notification notification = new NotificationCompat.Builder(Popup_todo_restart.this)
                        .setColor(ContextCompat.getColor(Popup_todo_restart.this, R.color.colorPrimary))
                        .setSmallIcon(R.drawable.school).setContentTitle(todo_title)
                        .setContentText(todo_content).setContentIntent(piMain).setAutoCancel(true)
                        .setGroup("HHS_Moodle")
                        .setStyle(new NotificationCompat.BigTextStyle().bigText(todo_content))
                        .setPriority(Notification.PRIORITY_DEFAULT).setVibrate(new long[0]).build();

                NotificationManager notificationManager = (NotificationManager) Popup_todo_restart.this
                        .getSystemService(NOTIFICATION_SERVICE);
                notificationManager.notify(n, notification);
                notificationManager.notify(0, builderSummary.build());
                break;
            }
            return v;
        }
    };

    lv.setAdapter(adapter);
    //onClick function
    try {
        helper_security.encrypt(Popup_todo_restart.this, "/databases/todo_DB_v01.db",
                "/databases/todo_DB_v01_en.db");
    } catch (Exception e) {
        e.printStackTrace();
    }

    new Handler().postDelayed(new Runnable() {
        public void run() {
            finish();
        }
    }, 1000);
}

From source file:org.videolan.vlc.gui.tv.RecommendationsService.java

private boolean doRecommendations() {
    mNotificationManager.cancelAll();//from www  .ja  v a  2 s  . c o m
    String last = Uri.decode(PreferenceManager.getDefaultSharedPreferences(mContext)
            .getString(PreferencesActivity.VIDEO_LAST, null));
    int id = 0;
    if (last != null) {
        buildRecommendation(MediaLibrary.getInstance().getMediaItem(last), id, Notification.PRIORITY_HIGH);
    }
    ArrayList<MediaWrapper> videoList = MediaLibrary.getInstance().getVideoItems();
    if (videoList == null || videoList.isEmpty())
        return false;
    Bitmap pic;
    Collections.shuffle(videoList);
    for (MediaWrapper mediaWrapper : videoList) {
        if (TextUtils.equals(mediaWrapper.getLocation(), last))
            continue;
        pic = mMediaDatabase.getPicture(mediaWrapper.getUri());
        if (pic != null && pic.getByteCount() > 4 && mediaWrapper.getTime() == 0) {
            buildRecommendation(mediaWrapper, ++id, Notification.PRIORITY_DEFAULT);
        }
        if (id == NUM_RECOMMANDATIONS)
            break;
    }
    return true;
}

From source file:rp.soi.dmsd.notextingwhilewalking.DetectedActivitiesIntentService.java

public void createNotification(boolean makeHeadsUpNotification) {

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_priority_high_black_24dp).setPriority(Notification.PRIORITY_DEFAULT)
            .setCategory(Notification.CATEGORY_MESSAGE).setContentTitle("No-Texting-While-Walking")
            .setContentText("It is hazardous to be texting while walking.");

    if (makeHeadsUpNotification) {

        Intent push = new Intent(getApplication(), MainActivity.class);
        push.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        //push.setClass(this, MainActivity.class);

        PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, push,
                PendingIntent.FLAG_CANCEL_CURRENT);
        notificationBuilder.setContentText("It is hazardous to be texting while walking.")
                .setFullScreenIntent(fullScreenPendingIntent, true);
    }/*from ww w  .j  a  v a2s  .  c om*/
    Notification notification = notificationBuilder.build();
    //---set the sound and lights---
    notification.defaults |= Notification.DEFAULT_SOUND;
    notification.defaults |= Notification.DEFAULT_LIGHTS;

    //---gets an instance of the NotificationManager service---
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);

    //---build the notification and issues it
    // with notification manager---
    notificationManager.notify(WEARABLE_NOTIFICATION_ID, notification);
}

From source file:de.baumann.hhsmoodle.popup.Popup_todo.java

private void setTodoList() {

    PreferenceManager.setDefaultValues(Popup_todo.this, R.xml.user_settings, false);
    final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(Popup_todo.this);

    NotificationManager nMgr = (NotificationManager) Popup_todo.this
            .getSystemService(Context.NOTIFICATION_SERVICE);
    nMgr.cancelAll();/*from   www.  j  a  va 2 s.co  m*/

    //display data
    final int layoutstyle = R.layout.list_item_notes;
    int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes };
    String[] column = new String[] { "todo_title", "todo_content", "todo_creation" };

    final String search = sharedPref.getString("filter_todo_subject", "");
    final Cursor row = db.fetchDataByFilter(search, "todo_title");
    final SimpleCursorAdapter adapter = new SimpleCursorAdapter(Popup_todo.this, layoutstyle, row, column,
            xml_id, 0) {
        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title"));
            final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content"));
            final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon"));
            final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment"));
            final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation"));

            View v = super.getView(position, convertView, parent);
            ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes);
            ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes);

            switch (todo_icon) {
            case "3":
                iv_icon.setImageResource(R.drawable.circle_green);
                break;
            case "2":
                iv_icon.setImageResource(R.drawable.circle_yellow);
                break;
            case "1":
                iv_icon.setImageResource(R.drawable.circle_red);
                break;
            }

            switch (todo_attachment) {
            case "true":
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.alert_circle);
                break;
            default:
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.alert_circle_red);

                int n = Integer.valueOf(_id);

                android.content.Intent iMain = new android.content.Intent();
                iMain.setAction("shortcutToDo");
                iMain.setClassName(Popup_todo.this, "de.baumann.hhsmoodle.activities.Activity_splash");
                PendingIntent piMain = PendingIntent.getActivity(Popup_todo.this, n, iMain, 0);

                NotificationCompat.Builder builderSummary = new NotificationCompat.Builder(Popup_todo.this)
                        .setSmallIcon(R.drawable.school)
                        .setColor(ContextCompat.getColor(Popup_todo.this, R.color.colorPrimary))
                        .setGroup("HHS_Moodle").setGroupSummary(true).setContentIntent(piMain);

                Notification notification = new NotificationCompat.Builder(Popup_todo.this)
                        .setColor(ContextCompat.getColor(Popup_todo.this, R.color.colorPrimary))
                        .setSmallIcon(R.drawable.school).setContentTitle(todo_title)
                        .setContentText(todo_content).setContentIntent(piMain).setAutoCancel(true)
                        .setGroup("HHS_Moodle")
                        .setStyle(new NotificationCompat.BigTextStyle().bigText(todo_content))
                        .setPriority(Notification.PRIORITY_DEFAULT).setVibrate(new long[0]).build();

                NotificationManager notificationManager = (NotificationManager) Popup_todo.this
                        .getSystemService(NOTIFICATION_SERVICE);
                notificationManager.notify(n, notification);
                notificationManager.notify(0, builderSummary.build());
                break;
            }

            iv_icon.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {

                    final Item[] items = {
                            new Item(getString(R.string.note_priority_0), R.drawable.circle_green),
                            new Item(getString(R.string.note_priority_1), R.drawable.circle_yellow),
                            new Item(getString(R.string.note_priority_2), R.drawable.circle_red), };

                    ListAdapter adapter = new ArrayAdapter<Item>(Popup_todo.this,
                            android.R.layout.select_dialog_item, android.R.id.text1, items) {
                        @NonNull
                        public View getView(int position, View convertView, @NonNull ViewGroup parent) {
                            //Use super class to create the View
                            View v = super.getView(position, convertView, parent);
                            TextView tv = (TextView) v.findViewById(android.R.id.text1);
                            tv.setTextSize(18);
                            tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0);
                            //Add margin between image and text (support various screen densities)
                            int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f);
                            tv.setCompoundDrawablePadding(dp5);

                            return v;
                        }
                    };

                    new AlertDialog.Builder(Popup_todo.this)
                            .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog, int whichButton) {
                                    dialog.cancel();
                                }
                            }).setAdapter(adapter, new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog, int item) {
                                    if (item == 0) {
                                        db.update(Integer.parseInt(_id), todo_title, todo_content, "3",
                                                todo_attachment, todo_creation);
                                        setTodoList();
                                    } else if (item == 1) {
                                        db.update(Integer.parseInt(_id), todo_title, todo_content, "2",
                                                todo_attachment, todo_creation);
                                        setTodoList();
                                    } else if (item == 2) {
                                        db.update(Integer.parseInt(_id), todo_title, todo_content, "1",
                                                todo_attachment, todo_creation);
                                        setTodoList();
                                    }
                                }
                            }).show();
                }
            });
            iv_attachment.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    switch (todo_attachment) {
                    case "true":
                        db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "",
                                todo_creation);
                        setTodoList();
                        break;
                    default:
                        db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "true",
                                todo_creation);
                        setTodoList();
                        break;
                    }
                }
            });
            return v;
        }
    };

    lv.setAdapter(adapter);
    //onClick function
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) {

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title"));
            final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content"));
            final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon"));
            final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment"));
            final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation"));

            sharedPref.edit().putString("toDo_title", todo_title).apply();
            sharedPref.edit().putString("toDo_text", todo_content).apply();
            sharedPref.edit().putString("toDo_seqno", _id).apply();
            sharedPref.edit().putString("toDo_icon", todo_icon).apply();
            sharedPref.edit().putString("toDo_create", todo_creation).apply();
            sharedPref.edit().putString("toDo_attachment", todo_attachment).apply();

            helper_main.switchToActivity(Popup_todo.this, Activity_todo.class, false);
        }
    });

    lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title"));
            final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content"));
            final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon"));
            final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment"));
            final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation"));

            final CharSequence[] options = { getString(R.string.bookmark_edit_title),
                    getString(R.string.todo_share), getString(R.string.bookmark_createNote),
                    getString(R.string.bookmark_createEvent), getString(R.string.bookmark_remove_bookmark) };
            new AlertDialog.Builder(Popup_todo.this)
                    .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.cancel();
                        }
                    }).setItems(options, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int item) {
                            if (options[item].equals(getString(R.string.bookmark_edit_title))) {

                                AlertDialog.Builder builder = new AlertDialog.Builder(Popup_todo.this);
                                View dialogView = View.inflate(Popup_todo.this, R.layout.dialog_edit_title,
                                        null);

                                final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title);
                                edit_title.setHint(R.string.bookmark_edit_title);
                                edit_title.setText(todo_title);

                                builder.setView(dialogView);
                                builder.setTitle(R.string.bookmark_edit_title);
                                builder.setPositiveButton(R.string.toast_yes,
                                        new DialogInterface.OnClickListener() {

                                            public void onClick(DialogInterface dialog, int whichButton) {

                                                String inputTag = edit_title.getText().toString().trim();
                                                db.update(Integer.parseInt(_id), inputTag, todo_content,
                                                        todo_icon, todo_attachment, todo_creation);
                                                setTodoList();
                                                Snackbar.make(lv, R.string.bookmark_added,
                                                        Snackbar.LENGTH_SHORT).show();
                                            }
                                        });
                                builder.setNegativeButton(R.string.toast_cancel,
                                        new DialogInterface.OnClickListener() {

                                            public void onClick(DialogInterface dialog, int whichButton) {
                                                dialog.cancel();
                                            }
                                        });

                                final AlertDialog dialog2 = builder.create();
                                // Display the custom alert dialog on interface
                                dialog2.show();
                                helper_main.showKeyboard(Popup_todo.this, edit_title);
                            }

                            if (options[item].equals(getString(R.string.todo_share))) {
                                Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                                sharingIntent.setType("text/plain");
                                sharingIntent.putExtra(Intent.EXTRA_SUBJECT, todo_title);
                                sharingIntent.putExtra(Intent.EXTRA_TEXT, todo_content);
                                startActivity(Intent.createChooser(sharingIntent,
                                        (getString(R.string.note_share_2))));
                            }

                            if (options[item].equals(getString(R.string.bookmark_createEvent))) {
                                Intent calIntent = new Intent(Intent.ACTION_INSERT);
                                calIntent.setType("vnd.android.cursor.item/event");
                                calIntent.putExtra(CalendarContract.Events.TITLE, todo_title);
                                calIntent.putExtra(CalendarContract.Events.DESCRIPTION, todo_content);
                                startActivity(calIntent);
                            }

                            if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) {
                                Snackbar snackbar = Snackbar
                                        .make(lv, R.string.note_remove_confirmation, Snackbar.LENGTH_LONG)
                                        .setAction(R.string.toast_yes, new View.OnClickListener() {
                                            @Override
                                            public void onClick(View view) {
                                                db.delete(Integer.parseInt(_id));
                                                setTodoList();
                                            }
                                        });
                                snackbar.show();
                            }

                            if (options[item].equals(getString(R.string.bookmark_createNote))) {
                                sharedPref.edit().putString("handleTextTitle", todo_title)
                                        .putString("handleTextText", todo_content).apply();
                                helper_main.switchToActivity(Popup_todo.this, Activity_EditNote.class, false);
                            }

                        }
                    }).show();

            return true;
        }
    });

    if (lv.getAdapter().getCount() == 0) {
        new android.app.AlertDialog.Builder(this)
                .setMessage(helper_main.textSpannable(getString(R.string.toast_noEntry)))
                .setPositiveButton(this.getString(R.string.toast_yes), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        finish();
                    }
                }).show();
        new Handler().postDelayed(new Runnable() {
            public void run() {
                finish();
            }
        }, 2000);
    }
}