當前位置: 首頁>>代碼示例>>Java>>正文


Java Builder.setDeleteIntent方法代碼示例

本文整理匯總了Java中android.support.v4.app.NotificationCompat.Builder.setDeleteIntent方法的典型用法代碼示例。如果您正苦於以下問題:Java Builder.setDeleteIntent方法的具體用法?Java Builder.setDeleteIntent怎麽用?Java Builder.setDeleteIntent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.app.NotificationCompat.Builder的用法示例。


在下文中一共展示了Builder.setDeleteIntent方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildSummary

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public Notification buildSummary(Context context, NotificationManager manager, String group, List<NotificationMessage> messages) {
    NotificationCompat.WearableExtender extender = new NotificationCompat.WearableExtender();

    Intent intent = new Intent(context, NotificationIntentService.class);
    manager.setCancelAll(intent, group);
    intent.setData(Uri.parse("nuclei://notifications?_g=" + group));
    PendingIntent pendingIntent = PendingIntent.getService(context, getDeleteIntentRequestId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);

    Builder builder = new Builder(context)
            .setSmallIcon(manager.getDefaultSmallIcon())
            .setLargeIcon(manager.getDefaultLargeIcon())
            .setAutoCancel(true)
            .setGroup(group)
            .setGroupSummary(true);

    onBuildSummary(context, manager, builder, extender, group, messages);

    builder.setDeleteIntent(pendingIntent);

    extender.extend(builder);

    return builder.build();
}
 
開發者ID:lifechurch,項目名稱:nuclei-android,代碼行數:24,代碼來源:NotificationBuilder.java

示例2: buildNotification

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public Notification buildNotification(Context context, NotificationManager manager, NotificationMessage message, List<NotificationMessage> messages) {
    NotificationCompat.WearableExtender extender = new NotificationCompat.WearableExtender();

    Intent intent = new Intent(context, NotificationIntentService.class);
    manager.setCancelMessage(intent, message);
    intent.setData(Uri.parse("nuclei://notifications?_id=" + message._id + "&_g=" + message.groupKey));
    PendingIntent pendingIntent = PendingIntent.getService(context, getDeleteIntentRequestId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);

    Builder builder = new Builder(context)
            .setSmallIcon(manager.getDefaultSmallIcon())
            .setLargeIcon(manager.getDefaultLargeIcon())
            .setOngoing(false)
            .setAutoCancel(true);

    if (messages.size() > 1) {
        builder.setGroup(message.groupKey).setGroupSummary(false);
    }

    onBuildNotification(context, manager, builder, extender, message);

    builder.setDeleteIntent(pendingIntent);

    extender.extend(builder);

    return builder.build();
}
 
開發者ID:lifechurch,項目名稱:nuclei-android,代碼行數:27,代碼來源:NotificationBuilder.java

示例3: updateNotification

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void updateNotification(final boolean notify) {
	final NotificationManager notificationManager = (NotificationManager) mXmppConnectionService
		.getSystemService(Context.NOTIFICATION_SERVICE);
	final SharedPreferences preferences = mXmppConnectionService.getPreferences();

	final String ringtone = preferences.getString("notification_ringtone", null);
	final boolean vibrate = preferences.getBoolean("vibrate_on_notification", true);

	if (notifications.size() == 0) {
		notificationManager.cancel(NOTIFICATION_ID);
	} else {
		if (notify) {
			this.markLastNotification();
		}
		final Builder mBuilder;
		if (notifications.size() == 1) {
			mBuilder = buildSingleConversations(notify);
		} else {
			mBuilder = buildMultipleConversation();
		}
		if (notify && !isQuietHours()) {
			if (vibrate) {
				final int dat = 70;
				final long[] pattern = {0, 3 * dat, dat, dat};
				mBuilder.setVibrate(pattern);
			}
			if (ringtone != null) {
				mBuilder.setSound(Uri.parse(ringtone));
			}
		}
		mBuilder.setSmallIcon(R.drawable.ic_notification);
		mBuilder.setDeleteIntent(createDeleteIntent());
		mBuilder.setLights(0xffffffff, 2000, 4000);
		final Notification notification = mBuilder.build();
		notificationManager.notify(NOTIFICATION_ID, notification);
	}
}
 
開發者ID:juanignaciomolina,項目名稱:txtr,代碼行數:38,代碼來源:NotificationService.java

示例4: buildMultipleConversation

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildMultipleConversation() {
	final Builder mBuilder = new NotificationCompat.Builder(
			mXmppConnectionService);
	final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
	style.setBigContentTitle(notifications.size()
			+ " "
			+ mXmppConnectionService
			.getString(R.string.unread_conversations));
	final StringBuilder names = new StringBuilder();
	Conversation conversation = null;
	for (final ArrayList<Message> messages : notifications.values()) {
		if (messages.size() > 0) {
			conversation = messages.get(0).getConversation();
			final String name = conversation.getName();
			SpannableString styledString;
			if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
				int count = messages.size();
				styledString = new SpannableString(name + ": " + mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages,count,count));
				styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
				style.addLine(styledString);
			} else {
				styledString = new SpannableString(name + ": " + UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first);
				styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
				style.addLine(styledString);
			}
			names.append(name);
			names.append(", ");
		}
	}
	if (names.length() >= 2) {
		names.delete(names.length() - 2, names.length());
	}
	mBuilder.setContentTitle(notifications.size()
			+ " "
			+ mXmppConnectionService
			.getString(R.string.unread_conversations));
	mBuilder.setContentText(names.toString());
	mBuilder.setStyle(style);
	if (conversation != null) {
		mBuilder.setContentIntent(createContentIntent(conversation));
	}
	mBuilder.setGroupSummary(true);
	mBuilder.setGroup(CONVERSATIONS_GROUP);
	mBuilder.setDeleteIntent(createDeleteIntent(null));
	mBuilder.setSmallIcon(R.drawable.ic_notification);
	return mBuilder;
}
 
開發者ID:syntafin,項目名稱:TenguChat,代碼行數:48,代碼來源:NotificationService.java

示例5: buildSingleConversations

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildSingleConversations(final ArrayList<Message> messages) {
	final Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);
	if (messages.size() >= 1) {
		final Conversation conversation = messages.get(0).getConversation();
		final UnreadConversation.Builder mUnreadBuilder = new UnreadConversation.Builder(conversation.getName());
		mBuilder.setLargeIcon(mXmppConnectionService.getAvatarService()
				.get(conversation, getPixel(64)));
		mBuilder.setContentTitle(conversation.getName());
		if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
			int count = messages.size();
			mBuilder.setContentText(mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages,count,count));
		} else {
			Message message;
			if ((message = getImage(messages)) != null) {
				modifyForImage(mBuilder, mUnreadBuilder, message, messages);
			} else {
				modifyForTextOnly(mBuilder, mUnreadBuilder, messages);
			}
			RemoteInput remoteInput = new RemoteInput.Builder("text_reply").setLabel(UIHelper.getMessageHint(mXmppConnectionService, conversation)).build();
			NotificationCompat.Action markReadAction = new NotificationCompat.Action.Builder(R.drawable.ic_send_text_offline, "Mark As Read", createReadPendingIntent(conversation)).build();
			NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(R.drawable.ic_send_text_offline, "Reply", createReplyIntent(conversation, false)).addRemoteInput(remoteInput).build();
			NotificationCompat.Action wearReplyAction = new NotificationCompat.Action.Builder(R.drawable.ic_wear_reply, "Reply", createReplyIntent(conversation, true)).addRemoteInput(remoteInput).build();
			mBuilder.extend(new NotificationCompat.WearableExtender().addAction(wearReplyAction));
			mUnreadBuilder.setReplyAction(createReplyIntent(conversation, true), remoteInput);
			mUnreadBuilder.setReadPendingIntent(createReadPendingIntent(conversation));
			mBuilder.extend(new NotificationCompat.CarExtender().setUnreadConversation(mUnreadBuilder.build()));
			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
				mBuilder.addAction(markReadAction);
				mBuilder.addAction(replyAction);
			}
			if ((message = getFirstDownloadableMessage(messages)) != null) {
				mBuilder.addAction(
						Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
								R.drawable.ic_file_download_white_24dp : R.drawable.ic_action_download,
						mXmppConnectionService.getResources().getString(R.string.download_x_file,
								UIHelper.getFileDescriptionString(mXmppConnectionService, message)),
						createDownloadIntent(message)
				);
			}
			if ((message = getFirstLocationMessage(messages)) != null) {
				mBuilder.addAction(R.drawable.ic_room_white_24dp,
						mXmppConnectionService.getString(R.string.show_location),
						createShowLocationIntent(message));
			}
		}
		if (conversation.getMode() == Conversation.MODE_SINGLE) {
			Contact contact = conversation.getContact();
			Uri systemAccount = contact.getSystemAccount();
			if (systemAccount != null) {
				mBuilder.addPerson(systemAccount.toString());
			}
		}
		mBuilder.setWhen(conversation.getLatestMessage().getTimeSent());
		mBuilder.setSmallIcon(R.drawable.ic_notification);
		mBuilder.setDeleteIntent(createDeleteIntent(conversation));
		mBuilder.setContentIntent(createContentIntent(conversation));
	}
	return mBuilder;
}
 
開發者ID:syntafin,項目名稱:TenguChat,代碼行數:60,代碼來源:NotificationService.java

示例6: updateNotification

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public void updateNotification(final boolean notify) {
	final NotificationManager notificationManager = (NotificationManager) mXmppConnectionService
			.getSystemService(Context.NOTIFICATION_SERVICE);
	final SharedPreferences preferences = mXmppConnectionService.getPreferences();

	final String ringtone = preferences.getString("notification_ringtone", null);
	final boolean vibrate = preferences.getBoolean("vibrate_on_notification", true);

	if (notifications.size() == 0) {
		notificationManager.cancel(NOTIFICATION_ID);
	} else {
		if (notify) {
			this.markLastNotification();
		}
		final Builder mBuilder;
		if (notifications.size() == 1) {
			mBuilder = buildSingleConversations(notify);
		} else {
			mBuilder = buildMultipleConversation();
		}
		if (notify && !isQuietHours()) {
			if (vibrate) {
				final int dat = 70;
				final long[] pattern = {0, 3 * dat, dat, dat};
				mBuilder.setVibrate(pattern);
			}
			if (ringtone != null) {
				mBuilder.setSound(Uri.parse(ringtone));
			}
		}
		if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
			mBuilder.setCategory(Notification.CATEGORY_MESSAGE);
		}
		setNotificationColor(mBuilder);
		mBuilder.setDefaults(0);
		mBuilder.setSmallIcon(R.drawable.ic_notification);
		mBuilder.setDeleteIntent(createDeleteIntent());
		mBuilder.setLights(0xff00FF00, 2000, 3000);
		final Notification notification = mBuilder.build();
		notificationManager.notify(NOTIFICATION_ID, notification);
	}
}
 
開發者ID:xavierle,項目名稱:messengerxmpp,代碼行數:43,代碼來源:NotificationService.java

示例7: buildMultipleConversation

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildMultipleConversation() {
    final Builder mBuilder = new NotificationCompat.Builder(
            mXmppConnectionService);
    final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
    style.setBigContentTitle(notifications.size()
            + " "
            + mXmppConnectionService
            .getString(R.string.unread_conversations));
    final StringBuilder names = new StringBuilder();
    Conversation conversation = null;
    for (final ArrayList<Message> messages : notifications.values()) {
        if (messages.size() > 0) {
            conversation = messages.get(0).getConversation();
            final String name = conversation.getName();
            SpannableString styledString;
            if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
                int count = messages.size();
                styledString = new SpannableString(name + ": " + mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages, count, count));
                styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
                style.addLine(styledString);
            } else {
                styledString = new SpannableString(name + ": " + UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first);
                styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
                style.addLine(styledString);
            }
            names.append(name);
            names.append(", ");
        }
    }
    if (names.length() >= 2) {
        names.delete(names.length() - 2, names.length());
    }
    mBuilder.setContentTitle(notifications.size()
            + " "
            + mXmppConnectionService
            .getString(R.string.unread_conversations));
    mBuilder.setContentText(names.toString());
    mBuilder.setStyle(style);
    if (conversation != null) {
        mBuilder.setContentIntent(createContentIntent(conversation));
    }
    mBuilder.setGroupSummary(true);
    mBuilder.setGroup(CONVERSATIONS_GROUP);
    mBuilder.setDeleteIntent(createDeleteIntent(null));
    mBuilder.setSmallIcon(R.drawable.ic_notification);
    return mBuilder;
}
 
開發者ID:kriztan,項目名稱:Pix-Art-Messenger,代碼行數:48,代碼來源:NotificationService.java

示例8: buildSingleConversations

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildSingleConversations(final ArrayList<Message> messages) {
    final Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService);
    if (messages.size() >= 1) {
        final Conversation conversation = messages.get(0).getConversation();
        final UnreadConversation.Builder mUnreadBuilder = new UnreadConversation.Builder(conversation.getName());
        mBuilder.setLargeIcon(mXmppConnectionService.getAvatarService()
                .get(conversation, getPixel(64)));
        mBuilder.setContentTitle(conversation.getName());
        if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
            int count = messages.size();
            mBuilder.setContentText(mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages, count, count));
        } else {
            Message message;
            if ((message = getImage(messages)) != null) {
                modifyForImage(mBuilder, mUnreadBuilder, message, messages);
            } else {
                modifyForTextOnly(mBuilder, mUnreadBuilder, messages);
            }
            RemoteInput remoteInput = new RemoteInput.Builder("text_reply").setLabel(UIHelper.getMessageHint(mXmppConnectionService, conversation)).build();
            NotificationCompat.Action markReadAction = new NotificationCompat.Action.Builder(R.drawable.ic_send_text_offline, mXmppConnectionService.getResources().getString(R.string.mark_as_read), createReadPendingIntent(conversation)).build();
            NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(R.drawable.ic_send_text_offline, mXmppConnectionService.getResources().getString(R.string.reply), createReplyIntent(conversation, false)).addRemoteInput(remoteInput).build();
            NotificationCompat.Action wearReplyAction = new NotificationCompat.Action.Builder(R.drawable.ic_wear_reply, "Reply", createReplyIntent(conversation, true)).addRemoteInput(remoteInput).build();
            mBuilder.extend(new NotificationCompat.WearableExtender().addAction(wearReplyAction));
            mUnreadBuilder.setReplyAction(createReplyIntent(conversation, true), remoteInput);
            mUnreadBuilder.setReadPendingIntent(createReadPendingIntent(conversation));
            mBuilder.extend(new NotificationCompat.CarExtender().setUnreadConversation(mUnreadBuilder.build()));
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                mBuilder.addAction(markReadAction);
                mBuilder.addAction(replyAction);
            }
            if ((message = getFirstDownloadableMessage(messages)) != null) {
                mBuilder.addAction(
                        Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
                                R.drawable.ic_file_download_white_24dp : R.drawable.ic_action_download,
                        mXmppConnectionService.getResources().getString(R.string.download_x_file,
                                UIHelper.getFileDescriptionString(mXmppConnectionService, message)),
                        createDownloadIntent(message)
                );
            }
            if ((message = getFirstLocationMessage(messages)) != null) {
                mBuilder.addAction(R.drawable.ic_room_white_24dp,
                        mXmppConnectionService.getString(R.string.show_location),
                        createShowLocationIntent(message));
            }
        }
        if (conversation.getMode() == Conversation.MODE_SINGLE) {
            Contact contact = conversation.getContact();
            Uri systemAccount = contact.getSystemAccount();
            if (systemAccount != null) {
                mBuilder.addPerson(systemAccount.toString());
            }
        }
        mBuilder.setWhen(conversation.getLatestMessage().getTimeSent());
        mBuilder.setSmallIcon(R.drawable.ic_notification);
        mBuilder.setDeleteIntent(createDeleteIntent(conversation));
        mBuilder.setContentIntent(createContentIntent(conversation));
    }
    return mBuilder;
}
 
開發者ID:kriztan,項目名稱:Pix-Art-Messenger,代碼行數:60,代碼來源:NotificationService.java

示例9: sendNotification

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public static void sendNotification(Context context, Builder builder)
{
	TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);

	Intent resultIntent = new Intent(context, MainActivity.class);
	resultIntent.putExtra(KlyphBundleExtras.SHOW_NOTIFICATION_MENU, true);

	stackBuilder.addNextIntentWithParentStack(resultIntent);

	int intentCode = (int) Math.round(Math.random() * 1000000);

	// Gets a PendingIntent containing the entire back stack
	PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(intentCode, PendingIntent.FLAG_UPDATE_CURRENT);
	builder.setContentIntent(resultPendingIntent);
	
	Intent intent = new Intent(context, NotificationGroupDeletedReceiver.class);
	builder.setDeleteIntent(PendingIntent.getBroadcast(context.getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));

	final NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

	final String tag = context.getPackageName() + "_grouped";
	final int id = 0;

	// pair (tag, id) must be unique
	// tag is the unique key
	mNotificationManager.notify(tag, id, builder.build());

}
 
開發者ID:jonathangerbaud,項目名稱:Klyph,代碼行數:29,代碼來源:KlyphNotification.java


注:本文中的android.support.v4.app.NotificationCompat.Builder.setDeleteIntent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。