当前位置: 首页>>代码示例>>Java>>正文


Java NotificationCompat.InboxStyle方法代码示例

本文整理汇总了Java中android.support.v4.app.NotificationCompat.InboxStyle方法的典型用法代码示例。如果您正苦于以下问题:Java NotificationCompat.InboxStyle方法的具体用法?Java NotificationCompat.InboxStyle怎么用?Java NotificationCompat.InboxStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.app.NotificationCompat的用法示例。


在下文中一共展示了NotificationCompat.InboxStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showSmallNotification

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void showSmallNotification(NotificationCompat.Builder mBuilder, int icon, String title, String message, String timeStamp, PendingIntent resultPendingIntent) {
    NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
    inboxStyle.addLine(message);
    Notification notification;
    notification = mBuilder.setSmallIcon(icon).setTicker(title).setWhen(0)
            .setAutoCancel(true)
            .setContentTitle(title)
            .setContentIntent(resultPendingIntent)
            .setStyle(inboxStyle)
            .setWhen(getTimeMilliSec(timeStamp))
            .setSmallIcon(R.drawable.logo)
            .setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
            .setContentText(message)
            .build();
    NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(Config.NOTIFICATION_ID, notification);
}
 
开发者ID:anandwana001,项目名称:Tech-Jalsa,代码行数:18,代码来源:NotificationUtils.java

示例2: sendNotification

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void sendNotification(String messageBody)
    {
        @SuppressWarnings("deprecation") NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle("Event tracker")
                .setContentText("Events received");

        NotificationCompat.InboxStyle inboxStyle =
                new NotificationCompat.InboxStyle();
        String[] events = new String[6];
        events[0] = messageBody;

        inboxStyle.setBigContentTitle("Event tracker details:");

        for (String s : events)
        {
            inboxStyle.addLine(s);
        }

        mBuilder.setStyle(inboxStyle);

        NotificationManager mNotificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
        mNotificationManager.notify(NOTIF_ID, mBuilder.build());
    }
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:27,代码来源:FirebaseMessaging.java

示例3: showSmallNotification

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void showSmallNotification(NotificationCompat.Builder mBuilder, int icon, String title, String message, String timeStamp, PendingIntent resultPendingIntent, Uri alarmSound) {

        NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();

        inboxStyle.addLine(message);

        Notification notification;
        notification = mBuilder.setSmallIcon(icon).setTicker(title).setWhen(0)
                .setAutoCancel(true)
                .setContentTitle(title)
                .setContentIntent(resultPendingIntent)
                .setSound(alarmSound)
                .setStyle(inboxStyle)
                .setWhen(DateUtils.currentTimeInMiles())
                .setSmallIcon(R.mipmap.ic_launcher)
                .setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
                .setContentText(message)
                .build();

        NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(ApplicationProps.NOTIFICATION_ID, notification);
    }
 
开发者ID:StringflowServer,项目名称:Beach-Android,代码行数:23,代码来源:NotificationUtils.java

示例4: getStyle

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private NotificationCompat.InboxStyle getStyle() {
    NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle()
            .setSummaryText(Utils.getController().getMessengerDatabase().getNotificationString())
            .setBigContentTitle(Utils.getString(R.string.messenger_notification_title));

    for (Message m : getUnreadMessages()) {
        String line = m.uname;

        if (Utils.getController().getMessengerDatabase().getType(m.cid) == Chat.ChatType.GROUP) {
            line += " @ " + m.cname;
        }

        line += ": " + m.mtext;

        style.addLine(line);
    }

    return style;
}
 
开发者ID:LCA311,项目名称:leoapp-sources,代码行数:20,代码来源:NotificationHandler.java

示例5: showSmallNotification

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void showSmallNotification(NotificationCompat.Builder builder, int icon, String title, String message, String timeStamp, PendingIntent resultPendingIntent) {
    NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
    inboxStyle.addLine(message);
    Notification notification = builder.setSmallIcon(icon).setTicker(title).setWhen(0)
            .setAutoCancel(true)
            .setContentTitle(title)
            .setContentIntent(resultPendingIntent)
            .setStyle(inboxStyle)
            .setWhen(getTimeMilliSec(timeStamp))
            .setSmallIcon(R.mipmap.iconcp)
            .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), icon))
            .setContentText(message)
            .build();
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(Config.NOTIFICATION_ID, notification);
}
 
开发者ID:akshah1997,项目名称:OSTMiniProject,代码行数:17,代码来源:NotificationUtils.java

示例6: showSmallNotification

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private void showSmallNotification(NotificationCompat.Builder mBuilder, int icon, String title, String message, String timeStamp, PendingIntent resultPendingIntent, Uri alarmSound) {

        NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();

        inboxStyle.addLine(message);

        Notification notification;
        notification = mBuilder.setSmallIcon(R.drawable.ic_launcher).setTicker(title).setWhen(0)
                .setAutoCancel(true)
                .setContentTitle(title)
                .setContentIntent(resultPendingIntent)
                .setSound(alarmSound)
                .setStyle(inboxStyle)
                .setWhen(getTimeMilliSec(timeStamp))
                .setSmallIcon(R.drawable.ic_launcher)
                .setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
                .setContentText(message)
                .build();

        NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(AppPrefs.NOTIFICATION_ID, notification);
    }
 
开发者ID:NarendraSickarwar,项目名称:FirebasePost,代码行数:23,代码来源:NotifactionUtil.java

示例7: build

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
@Override
public Notification build() {
  if (privacy.isDisplayMessage() || privacy.isDisplayContact()) {
    NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();

    for (CharSequence body : messageBodies) {
      style.addLine(body);
    }

    setStyle(style);
  }

  return super.build();
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:15,代码来源:MultipleRecipientNotificationBuilder.java

示例8: makeInboxStyle

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
public static NotificationCompat.InboxStyle makeInboxStyle(CharSequence title,
                                                           Collection<? extends CharSequence> lines) {
    NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle()
            .setBigContentTitle(title);
    for (CharSequence line : lines) {
        inboxStyle.addLine(line);
    }
    return inboxStyle;
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:10,代码来源:NotificationUtils.java

示例9: setInboxStyle

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
/**
 * API >= 16(JB) will work
 *
 * @param title
 * @param summary
 * @param contentLines
 * @return
 */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public NotificationEffect setInboxStyle(CharSequence title, CharSequence summary, CharSequence[] contentLines) {
    NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle()
            .setBigContentTitle(title)
            .setSummaryText(summary);
    for (int i = 0; i < contentLines.length; i++) {
        inboxStyle.addLine(contentLines[i]);
    }
    mBuilder.setStyle(inboxStyle);
    return new NotificationEffect(mContext, mBuilder);
}
 
开发者ID:cfryan1990,项目名称:NotificationCompat,代码行数:20,代码来源:NotificationStyle.java

示例10: makeInbox

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
public static NotificationCompat.InboxStyle makeInbox(List<String> messages) {
    NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
    for (CharSequence msg : messages) {
        style.addLine(msg);
    }
    return style;
}
 
开发者ID:czy1121,项目名称:NotificationDemo,代码行数:8,代码来源:NotifyUtil.java

示例11: show

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
public synchronized void show(HttpTransaction transaction) {
    addToBuffer(transaction);
    if (!BaseChuckActivity.isInForeground()) {
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                .setContentIntent(PendingIntent.getActivity(context, 0, Chuck.getLaunchIntent(context), 0))
                .setLocalOnly(true)
                .setSmallIcon(R.drawable.chuck_ic_notification_white_24dp)
                .setColor(ContextCompat.getColor(context, R.color.chuck_colorPrimary))
                .setContentTitle(context.getString(R.string.chuck_notification_title));
        NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
        if (setChannelId != null) {
            try { setChannelId.invoke(builder, CHANNEL_ID); } catch (Exception ignored) {}
        }
        int count = 0;
        for (int i = transactionBuffer.size() - 1; i >= 0; i--) {
            if (count < BUFFER_SIZE) {
                if (count == 0) {
                    builder.setContentText(transactionBuffer.valueAt(i).getNotificationText());
                }
                inboxStyle.addLine(transactionBuffer.valueAt(i).getNotificationText());
            }
            count++;
        }
        builder.setAutoCancel(true);
        builder.setStyle(inboxStyle);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            builder.setSubText(String.valueOf(transactionCount));
        } else {
            builder.setNumber(transactionCount);
        }
        builder.addAction(getClearAction());
        notificationManager.notify(NOTIFICATION_ID, builder.build());
    }
}
 
开发者ID:jgilfelt,项目名称:chuck,代码行数:35,代码来源:NotificationHelper.java

示例12: createUpdateSummaryNotification

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
private Notification createUpdateSummaryNotification(ArrayList<AppUpdateStatusManager.AppUpdateStatus> updates) {
    String title = context.getResources().getQuantityString(R.plurals.notification_summary_updates,
            updates.size(), updates.size());
    StringBuilder text = new StringBuilder();

    NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
    inboxStyle.setBigContentTitle(title);

    for (int i = 0; i < MAX_UPDATES_TO_SHOW && i < updates.size(); i++) {
        AppUpdateStatusManager.AppUpdateStatus entry = updates.get(i);
        App app = entry.app;
        AppUpdateStatusManager.Status status = entry.status;

        String content = getMultiItemContentString(app, status);
        SpannableStringBuilder sb = new SpannableStringBuilder(app.name);
        sb.setSpan(new StyleSpan(Typeface.BOLD), 0, sb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        sb.append(" ");
        sb.append(content);
        inboxStyle.addLine(sb);

        if (text.length() > 0) {
            text.append(", ");
        }
        text.append(app.name);
    }

    if (updates.size() > MAX_UPDATES_TO_SHOW) {
        int diff = updates.size() - MAX_UPDATES_TO_SHOW;
        inboxStyle.setSummaryText(context.getResources().getQuantityString(R.plurals.notification_summary_more,
                diff, diff));
    }

    // Intent to open main app list
    Intent intentObject = new Intent(context, MainActivity.class);
    intentObject.putExtra(MainActivity.EXTRA_VIEW_UPDATES, true);
    PendingIntent piAction = PendingIntent.getActivity(context, 0, intentObject, PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder builder =
            new NotificationCompat.Builder(context)
                    .setAutoCancel(!useStackedNotifications())
                    .setSmallIcon(R.drawable.ic_notification)
                    .setColor(ContextCompat.getColor(context, R.color.fdroid_blue))
                    .setContentTitle(title)
                    .setContentText(text)
                    .setContentIntent(piAction)
                    .setLocalOnly(true)
                    .setVisibility(NotificationCompat.VISIBILITY_SECRET)
                    .setStyle(inboxStyle);

    if (useStackedNotifications()) {
        builder.setGroup(GROUP_UPDATES)
                .setGroupSummary(true);
    }

    Intent intentDeleted = new Intent(BROADCAST_NOTIFICATIONS_ALL_UPDATES_CLEARED);
    intentDeleted.setClass(context, NotificationBroadcastReceiver.class);
    PendingIntent piDeleted = PendingIntent.getBroadcast(context, 0, intentDeleted, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setDeleteIntent(piDeleted);
    return builder.build();
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:61,代码来源:NotificationHelper.java

示例13: Inbox

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
public Inbox() {
    style = new NotificationCompat.InboxStyle();
}
 
开发者ID:boybeak,项目名称:NotificationStyles,代码行数:4,代码来源:Inbox.java

示例14: displayLocationBasedNotification

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
public static void displayLocationBasedNotification(Context context, int notificationId, String contentTitle, String contentText,
                                                    List<Task> triggeredTasks) {




    NotificationCompat.Builder mBuilder;
    mBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.icon_remindy_notification_small)
            .setColor(ContextCompat.getColor(context, R.color.primary))
            .setVibrate(new long[] { 50, 50, 200, 50 })
            .setLights(ContextCompat.getColor(context, R.color.primary), 3000, 3000)
            .setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
            .setContentTitle(contentTitle)
            .setContentText(contentText)
            .setAutoCancel(true)

            //Make notification pop-up in post 5.0 devices
            .setPriority(Notification.PRIORITY_HIGH);

    if(triggeredTasks.size() == 1) {

        //Intent for "DONE" button on BigView style
        Intent setTaskDoneIntent = new Intent(context, TaskActionsIntentService.class);
        setTaskDoneIntent.setAction(TaskActionsIntentService.ACTION_SET_TASK_DONE);
        setTaskDoneIntent.putExtra(TaskActionsIntentService.PARAM_TASK_ID, triggeredTasks.get(0).getId());
        PendingIntent setTaskDonePendingIntent = PendingIntent.getService(context, triggeredTasks.get(0).getId(), setTaskDoneIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        //Intent for clicking notification
        Intent openTaskIntent = new Intent(context, TaskDetailActivity.class);
        openTaskIntent.putExtra(TASK_ID_TO_DISPLAY, triggeredTasks.get(0).getId());
        //openTaskIntent.setAction(String.valueOf(task.getId()));
        //openTaskIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        //openTaskIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);


        TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);

        // Adds the back stack
        stackBuilder.addParentStack(TaskDetailActivity.class);
        // Adds the Intent to the top of the stack
        stackBuilder.addNextIntent(openTaskIntent);
        // Gets a PendingIntent containing the entire back stack
        PendingIntent openTaskPendingIntent = stackBuilder.getPendingIntent(triggeredTasks.get(0).getId(), PendingIntent.FLAG_UPDATE_CURRENT);


        //Add pendingIntent to notification
        mBuilder.setContentIntent(openTaskPendingIntent);
        mBuilder.addAction(R.drawable.icon_notification_done, context.getResources().getString(R.string.notification_big_view_set_done), setTaskDonePendingIntent);

        //Set BigView
        mBuilder.setStyle(new NotificationCompat.BigTextStyle()
                .bigText(contentText));

    } else {

        //Intent for clicking notification
        Intent openHomeIntent = new Intent(context, HomeActivity.class);
        PendingIntent openHomePendingItent = PendingIntent.getActivity(context, Integer.MAX_VALUE, openHomeIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        //InboxStyle BigView (Multiline!)
        NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
        inboxStyle.setBigContentTitle(contentTitle);
        for (Task task: triggeredTasks)
            inboxStyle.addLine("- " + task.getTitle());

        //Add pendingIntent to notification
        mBuilder.setContentIntent(openHomePendingItent);

        //Set BigView
        mBuilder.setStyle(inboxStyle);
    }


    // Get an instance of the NotificationManager service
    NotificationManager mNotifyMgr = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);

    // Builds the notification and issues it.
    mNotifyMgr.notify(triggeredTasks.get(0).getId(), mBuilder.build());
}
 
开发者ID:abicelis,项目名称:Remindy,代码行数:81,代码来源:NotificationUtil.java

示例15: run

import android.support.v4.app.NotificationCompat; //导入方法依赖的package包/类
@Override
public void run(Context context, Callback callback) {

    Intent i = new Intent(Intent.ACTION_VIEW,
            ScheduleContract.Sessions.buildSessionUri("__keynote__"));

    PendingIntent pi = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
    Intent mapIntent = new Intent(context, MapActivity.class);
    mapIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK |
            Intent.FLAG_ACTIVITY_TASK_ON_HOME);
    mapIntent.putExtra(MapActivity.EXTRA_ROOM, "keynote");
    PendingIntent piMap = TaskStackBuilder
            .create(context)
            .addNextIntent(mapIntent)
            .getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT);

     //= PendingIntent.getActivity(context, 0, mapIntent, 0);

    NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context)
            .setContentTitle("test notification")
            .setContentText("yep, this is a test")
            .setTicker("hey, you got a test")
            .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
            .setSmallIcon(R.drawable.ic_stat_notification)
            .setContentIntent(pi)
            .setPriority(Notification.PRIORITY_MAX)
            .setAutoCancel(true);
    notifBuilder.addAction(R.drawable.ic_map_holo_dark,
            context.getString(R.string.title_map),
            piMap);

    NotificationCompat.InboxStyle richNotification = new NotificationCompat.InboxStyle(
            notifBuilder)
            .setBigContentTitle(context.getResources().getQuantityString(R.plurals.session_notification_title,
                    1,
                    8,
                    1));

    NotificationManager nm = (NotificationManager) context.getSystemService(
            Context.NOTIFICATION_SERVICE);
    nm.notify(32534, richNotification.build());


}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:45,代码来源:ShowSessionNotificationDebugAction.java


注:本文中的android.support.v4.app.NotificationCompat.InboxStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。