Example usage for android.app Notification EXTRA_PEOPLE

List of usage examples for android.app Notification EXTRA_PEOPLE

Introduction

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

Prototype

String EXTRA_PEOPLE

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

Click Source Link

Document

#extras key: A String array containing the people that this notification relates to, each of which was supplied to Builder#addPerson(String) .

Usage

From source file:com.ademsha.appnotifico.NotificationDataHelper.java

@TargetApi(Build.VERSION_CODES.KITKAT)
private static JSONObject getNotificationExtras(JSONObject notification,
        StatusBarNotification statusBarNotification) {
    try {//from   www. ja  v  a 2  s . c o m
        Bundle extras = statusBarNotification.getNotification().extras;
        if (extras != null) {
            notification.put("text", extras.getString(Notification.EXTRA_TEXT));
            notification.put("sub_text", extras.getString(Notification.EXTRA_SUB_TEXT));
            notification.put("summary_text", extras.getString(Notification.EXTRA_SUMMARY_TEXT));
            notification.put("text_lines", Arrays
                    .toString(extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES)).replace("null", ""));
            notification.put("icon", String.valueOf(extras.getInt(Notification.EXTRA_SMALL_ICON)));
            if (extras.getParcelable(Notification.EXTRA_LARGE_ICON) != null) {
                notification.put("large_icon",
                        String.valueOf(extras.getParcelable(Notification.EXTRA_LARGE_ICON).toString())
                                .replace("null", ""));
            }
            notification.put("title", extras.getString(Notification.EXTRA_TITLE));
            notification.put("title_big", extras.getString(Notification.EXTRA_TITLE_BIG));
            notification.put("progress", extras.getInt(Notification.EXTRA_PROGRESS));
            notification.put("progress_indeterminate",
                    String.valueOf(extras.getBoolean(Notification.EXTRA_PROGRESS_INDETERMINATE)));
            notification.put("progress_max", String.valueOf(extras.getInt(Notification.EXTRA_PROGRESS_MAX)));
            notification.put("people", extras.getStringArray(Notification.EXTRA_PEOPLE));
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return notification;
}

From source file:com.bluelinelabs.logansquare.typeconverters.NotificationConverter.java

@TargetApi(Build.VERSION_CODES.KITKAT)
@NonNull/* w  w  w.j av  a2s . c o m*/
public static SimpleNotification toSimpleNotification(@NonNull Notification notification) {
    SimpleNotification simpleNotification = new SimpleNotification();

    simpleNotification.autoCancel = (notification.flags
            & Notification.FLAG_AUTO_CANCEL) == Notification.FLAG_AUTO_CANCEL;
    android.util.Log.d("json2notification", "autoCancel:" + simpleNotification.autoCancel);

    //simpleNotification.bigPictureStyle // TODO

    simpleNotification.category = notification.category;
    simpleNotification.color = notification.color > 0 ? notification.color : null;
    simpleNotification.contentInfo = notification.extras.getString(Notification.EXTRA_INFO_TEXT);
    simpleNotification.contentIntent = notification.contentIntent;
    simpleNotification.contentTitle = notification.extras.getString(Notification.EXTRA_TITLE);
    simpleNotification.contentText = notification.extras.getString(Notification.EXTRA_TEXT);
    simpleNotification.defaults = notification.defaults > 0 ? notification.defaults : null;
    simpleNotification.deleteIntent = notification.deleteIntent;
    //simpleNotification.extras;
    simpleNotification.groupKey = notification.getGroup();
    if (simpleNotification.groupKey != null) {
        simpleNotification.groupSummary = (notification.flags
                & Notification.FLAG_GROUP_SUMMARY) == Notification.FLAG_GROUP_SUMMARY;
    }
    Bitmap bitmap = notification.extras.getParcelable(Notification.EXTRA_LARGE_ICON);
    if (bitmap != null)
        simpleNotification.largeIcon = Bitmaps.base64(bitmap);
    if ((notification.flags & Notification.FLAG_SHOW_LIGHTS) == Notification.FLAG_SHOW_LIGHTS) {
        simpleNotification.lights = Arrays.asList(notification.ledARGB, notification.ledOnMS,
                notification.ledOffMS);
    }
    simpleNotification.localOnly = (notification.flags
            & Notification.FLAG_LOCAL_ONLY) == Notification.FLAG_LOCAL_ONLY;
    simpleNotification.number = notification.number > 0 ? notification.number : null;
    simpleNotification.ongoing = (notification.flags
            & Notification.FLAG_ONGOING_EVENT) == Notification.FLAG_ONGOING_EVENT;
    simpleNotification.onlyAlertOnce = (notification.flags
            & Notification.FLAG_ONLY_ALERT_ONCE) == Notification.FLAG_ONLY_ALERT_ONCE;
    String[] people = notification.extras.getStringArray(Notification.EXTRA_PEOPLE);
    if (people != null) {
        simpleNotification.people = Arrays.asList(people);
    }
    simpleNotification.priority = notification.priority > 0 ? notification.priority : null;
    //simpleNotification.progress;
    simpleNotification.publicVersion = notification.publicVersion;
    simpleNotification.showWhen = notification.extras.getBoolean(Notification.EXTRA_SHOW_WHEN);
    if (simpleNotification.showWhen) {
        simpleNotification.when = notification.when;
    }
    simpleNotification.smallIcon = String.valueOf(notification.extras.getInt(Notification.EXTRA_SMALL_ICON)); // TODO getResourceNameById()
    android.util.Log.d("json2notification", "simpleNotification.smallIcon" + simpleNotification.smallIcon);
    simpleNotification.sortKey = notification.getSortKey();
    simpleNotification.sound = notification.sound;
    simpleNotification.subText = notification.extras.getString(Notification.EXTRA_SUB_TEXT);
    simpleNotification.tickerText = notification.tickerText;
    simpleNotification.usesChronometer = notification.extras.getBoolean(Notification.EXTRA_SHOW_CHRONOMETER);
    simpleNotification.visibility = notification.visibility > 0 ? notification.visibility : null;
    return simpleNotification;
}