Example usage for android.app Notification EXTRA_TEXT_LINES

List of usage examples for android.app Notification EXTRA_TEXT_LINES

Introduction

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

Prototype

String EXTRA_TEXT_LINES

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

Click Source Link

Document

#extras key: An array of CharSequences to show in InboxStyle expanded notifications, each of which was supplied to InboxStyle#addLine(CharSequence) .

Usage

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

@TargetApi(Build.VERSION_CODES.KITKAT)
private static JSONObject getNotificationExtras(JSONObject notification,
        StatusBarNotification statusBarNotification) {
    try {//  w  w  w. java2 s.  com
        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.test.onesignal.GenerateNotificationRunner.java

private void testNotificationExtenderServiceOverridePropertiesWithSummary() throws Exception {
    Bundle bundle = getBaseNotifBundle("UUID1");
    bundle.putString("grp", "test1");

    startNotificationExtender(createInternalPayloadBundle(bundle),
            NotificationExtenderServiceOverrideProperties.class);

    bundle = getBaseNotifBundle("UUID2");
    bundle.putString("grp", "test1");

    startNotificationExtender(createInternalPayloadBundle(bundle),
            NotificationExtenderServiceOverrideProperties.class);

    Map<Integer, PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications;
    Iterator<Map.Entry<Integer, PostedNotification>> postedNotifsIterator = postedNotifs.entrySet().iterator();

    // Test - First notification should be the summary
    PostedNotification postedSummaryNotification = postedNotifsIterator.next().getValue();
    Assert.assertEquals("2 new messages", postedSummaryNotification.getShadow().getContentText());
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT)
        Assert.assertEquals(Notification.FLAG_GROUP_SUMMARY,
                postedSummaryNotification.notif.flags & Notification.FLAG_GROUP_SUMMARY);

    // Test - Make sure summary build saved and used the developer's extender settings for the body and title
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) {
        CharSequence[] lines = postedSummaryNotification.notif.extras
                .getCharSequenceArray(Notification.EXTRA_TEXT_LINES);
        for (CharSequence line : lines)
            Assert.assertEquals("[Modified Tile] [Modified Body(ContentText)]", line.toString());
    }// w w  w. j ava 2s .co m
}