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


Java Builder.setContentText方法代碼示例

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


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

示例1: displayOpenFileNotification

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void displayOpenFileNotification() {
    Intent notificationIntent = getOpenIntent();
    int icon =  R.mipmap.video2;
    CharSequence title = getResources().getText(R.string.open_file);
    long when = System.currentTimeMillis();
    PendingIntent contentIntent = PendingIntent.getBroadcast(this, 0, notificationIntent, 0);
    Builder notificationBuilder = new NotificationCompat.Builder(this);
    notificationBuilder.setSmallIcon(icon);
    notificationBuilder.setTicker(null);
    notificationBuilder.setOnlyAlertOnce(true);
    notificationBuilder.setContentTitle(title);
    notificationBuilder.setContentText(mProcessedFiles.get(0).getName());
    notificationBuilder.setContentIntent(contentIntent);
    notificationBuilder.setWhen(when);
    notificationBuilder.setDefaults(0); // no sound, no light, no vibrate
    mNotificationManager.notify(OPEN_NOTIFICATION_ID, notificationBuilder.build());
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:18,代碼來源:FileManagerService.java

示例2: modifyForConference

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForConference(Builder builder, Conversation conversation, List<Message> messages, boolean notify) {
	final Message first = messages.get(0);
	final Message last = messages.get(messages.size() - 1);
	final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
	style.setBigContentTitle(conversation.getName());

	for(Message message : messages) {
		if (message.hasMeCommand()) {
			style.addLine(UIHelper.getMessagePreview(mXmppConnectionService,message).first);
		} else {
			style.addLine(Html.fromHtml("<b>" + UIHelper.getMessageDisplayName(message) + "</b>: " + UIHelper.getMessagePreview(mXmppConnectionService, message).first));
		}
	}
	builder.setContentText((first.hasMeCommand() ? "" :UIHelper.getMessageDisplayName(first)+ ": ") +UIHelper.getMessagePreview(mXmppConnectionService, first).first);
	builder.setStyle(style);
	if (notify) {
		builder.setTicker((last.hasMeCommand() ? "" : UIHelper.getMessageDisplayName(last) + ": ") + UIHelper.getMessagePreview(mXmppConnectionService,last).first);
	}
}
 
開發者ID:Frozenbox,項目名稱:frozenchat,代碼行數:20,代碼來源:NotificationService.java

示例3: modifyForImage

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForImage(final Builder builder, final Message message,
		final ArrayList<Message> messages, final boolean notify) {
	try {
		final Bitmap bitmap = mXmppConnectionService.getFileBackend()
			.getThumbnail(message, getPixel(288), false);
		final ArrayList<Message> tmp = new ArrayList<>();
		for (final Message msg : messages) {
			if (msg.getType() == Message.TYPE_TEXT
					&& msg.getDownloadable() == null) {
				tmp.add(msg);
					}
		}
		final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
		bigPictureStyle.bigPicture(bitmap);
		if (tmp.size() > 0) {
			bigPictureStyle.setSummaryText(getMergedBodies(tmp));
			builder.setContentText(getReadableBody(tmp.get(0)));
		} else {
			builder.setContentText(mXmppConnectionService.getString(R.string.image_file));
		}
		builder.setStyle(bigPictureStyle);
	} catch (final FileNotFoundException e) {
		modifyForTextOnly(builder, messages, notify);
	}
}
 
開發者ID:juanignaciomolina,項目名稱:txtr,代碼行數:26,代碼來源:NotificationService.java

示例4: Noti

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
void Noti(int d){
	notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
	Builder notiBuilder = new NotificationCompat.Builder(getApplicationContext());
	notiBuilder.setSmallIcon(R.drawable.ic_launcher);
       notiBuilder.setContentTitle("PopBell Plugin 테스트하기");
       notiBuilder.setContentText("안드로이드 테스트 " + i);
       notiBuilder.setWhen(when);
       Notification noti = notiBuilder.build();
	if(d == 0){
		i++;
        notificationManager.notify("Popbell", notiid, noti);
	}else if(d == 1){
		notificationManager.cancel("Popbell", notiid);
		finish();
	}
}
 
開發者ID:SimpleMinds,項目名稱:PopBell,代碼行數:17,代碼來源:MainActivity.java

示例5: createPublicNotificationWithSenderList

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Notification createPublicNotificationWithSenderList(NotificationData notificationData) {
    Builder builder = createPublicNotification(notificationData);
    int newMessages = notificationData.getNewMessagesCount();
    if (newMessages == 1) {
        NotificationHolder holder = notificationData.getHolderForLatestNotification();
        builder.setContentText(holder.content.sender);
    } else {
        List<NotificationContent> contents = notificationData.getContentForSummaryNotification();
        String senderList = createCommaSeparatedListOfSenders(contents);
        builder.setContentText(senderList);
    }

    return builder.build();
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:15,代碼來源:LockScreenNotification.java

示例6: createPublicNotificationWithNewMessagesCount

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Notification createPublicNotificationWithNewMessagesCount(NotificationData notificationData) {
    Builder builder = createPublicNotification(notificationData);
    Account account = notificationData.getAccount();
    String accountName = controller.getAccountName(account);
    builder.setContentText(accountName);

    return builder.build();
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:9,代碼來源:LockScreenNotification.java

示例7: showNotification

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void showNotification(String animeURL) {
    // Build notification
    Builder notificationBuilder = new Builder(mContext);
    notificationBuilder.setWhen(System.currentTimeMillis());
    notificationBuilder.setContentTitle(animeURL);
    notificationBuilder.setContentText("Parsing required anime data");

    notificationBuilder.setSmallIcon(android.R.drawable.stat_sys_download);
    notificationBuilder.setOngoing(false);
    notificationBuilder.setProgress(0, 0, true);
    Intent i = new Intent(mContext, MainActivity.class);
    notificationBuilder.setContentIntent(PendingIntent.getActivity(mContext, animeURL.hashCode(), i, PendingIntent.FLAG_UPDATE_CURRENT));

    /**
     RemoteViews contentView = new RemoteViews(mContext.getApplicationContext().getPackageName(), R.layout.download_notif_dark);
     contentView.setImageViewResource(R.id.status_icon, R.mipmap.ic_launcher);
     contentView.setTextViewText(R.id.status_text, "Parsing missing anime " + animeURL);
     contentView.setProgressBar(R.id.status_progress, 50, 0, true);
     contentView.setViewVisibility(R.id.status_progress_wrapper, View.VISIBLE);
     notificationBuilder.setContent(contentView);
     Intent i = new Intent(mContext, MainActivity.class);
     notificationBuilder.setContentIntent(PendingIntent.getActivity(mContext, animeURL.hashCode(), i, PendingIntent.FLAG_UPDATE_CURRENT));

     final Notification notification = notificationBuilder.getNotification();
     notification.contentView = contentView;
     **/

    if (notificationBuilder != null) {
        mNotificationMap.put(animeURL.hashCode(), animeURL.hashCode());
        mNotificationManager.notify(animeURL.hashCode(), notificationBuilder.build());
    }
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:33,代碼來源:ParseAnimeService.java

示例8: modifyForImage

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForImage(final Builder builder, final UnreadConversation.Builder uBuilder,
							final Message message, final ArrayList<Message> messages) {
	try {
		final Bitmap bitmap = mXmppConnectionService.getFileBackend()
				.getThumbnail(message, getPixel(288), false);
		final ArrayList<Message> tmp = new ArrayList<>();
		for (final Message msg : messages) {
			if (msg.getType() == Message.TYPE_TEXT
					&& msg.getTransferable() == null) {
				tmp.add(msg);
			}
		}
		final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
		bigPictureStyle.bigPicture(bitmap);
		if (tmp.size() > 0) {
			CharSequence text = getMergedBodies(tmp);
			bigPictureStyle.setSummaryText(text);
			builder.setContentText(text);
		} else {
			builder.setContentText(mXmppConnectionService.getString(
					R.string.received_x_file,
					UIHelper.getFileDescriptionString(mXmppConnectionService, message)));
		}
		builder.setStyle(bigPictureStyle);
	} catch (final FileNotFoundException e) {
		modifyForTextOnly(builder, uBuilder, messages);
	}
}
 
開發者ID:syntafin,項目名稱:TenguChat,代碼行數:29,代碼來源:NotificationService.java

示例9: sendNotification

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public static void sendNotification(Context ctx, String title,
		String content, int max, int progress, int iconRes, int id) {

	Builder builder = new Builder(ctx);
	builder.setContentTitle(title);
	builder.setAutoCancel(false);
	builder.setContentText(content);
	builder.setProgress(max, progress, true);
	builder.setSmallIcon(iconRes);
	NotificationManager manager = (NotificationManager) ctx
			.getSystemService(Context.NOTIFICATION_SERVICE);
	manager.notify(id, builder.build());
}
 
開發者ID:jacklongway,項目名稱:LiteSDK,代碼行數:14,代碼來源:NotificationUtil.java

示例10: 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();
			if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
				int count = messages.size();
				style.addLine(Html.fromHtml("<b>"+name+"</b> "+mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages,count,count)));
			} else {
				style.addLine(Html.fromHtml("<b>" + name + "</b> "
						+ UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first));
			}
			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));
	}
	return mBuilder;
}
 
開發者ID:xavierle,項目名稱:messengerxmpp,代碼行數:40,代碼來源:NotificationService.java

示例11: buildSingleConversations

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildSingleConversations(final boolean notify) {
	final Builder mBuilder = new NotificationCompat.Builder(
			mXmppConnectionService);
	final ArrayList<Message> messages = notifications.values().iterator().next();
	if (messages.size() >= 1) {
		final Conversation conversation = messages.get(0).getConversation();
		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, message, messages, notify);
			} else if (conversation.getMode() == Conversation.MODE_MULTI) {
				modifyForConference(mBuilder, conversation, messages, notify);
			} else {
				modifyForTextOnly(mBuilder, messages, notify);
			}
			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));
			}
		}
		mBuilder.setContentIntent(createContentIntent(conversation));
	}
	return mBuilder;
}
 
開發者ID:xavierle,項目名稱:messengerxmpp,代碼行數:41,代碼來源:NotificationService.java

示例12: modifyForImage

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForImage(final Builder builder, final Message message,
							final ArrayList<Message> messages, final boolean notify) {
	try {
		final Bitmap bitmap = mXmppConnectionService.getFileBackend()
				.getThumbnail(message, getPixel(288), false);
		final ArrayList<Message> tmp = new ArrayList<>();
		for (final Message msg : messages) {
			if (msg.getType() == Message.TYPE_TEXT
					&& msg.getTransferable() == null) {
				tmp.add(msg);
			}
		}
		final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
		bigPictureStyle.bigPicture(bitmap);
		if (tmp.size() > 0) {
			bigPictureStyle.setSummaryText(getMergedBodies(tmp));
			builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, tmp.get(0)).first);
		} else {
			builder.setContentText(mXmppConnectionService.getString(
					R.string.received_x_file,
					UIHelper.getFileDescriptionString(mXmppConnectionService, message)));
		}
		builder.setStyle(bigPictureStyle);
	} catch (final FileNotFoundException e) {
		modifyForTextOnly(builder, messages, notify);
	}
}
 
開發者ID:xavierle,項目名稱:messengerxmpp,代碼行數:28,代碼來源:NotificationService.java

示例13: modifyForTextOnly

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForTextOnly(final Builder builder,
							   final ArrayList<Message> messages, final boolean notify) {
	builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages)));
	builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first);
	if (notify) {
		builder.setTicker(UIHelper.getMessagePreview(mXmppConnectionService, messages.get(messages.size() - 1)).first);
	}
}
 
開發者ID:xavierle,項目名稱:messengerxmpp,代碼行數:9,代碼來源:NotificationService.java

示例14: modifyForConference

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForConference(Builder builder, Conversation conversation, List<Message> messages, boolean notify) {
	final Message first = messages.get(0);
	final Message last = messages.get(messages.size() - 1);
	final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
	style.setBigContentTitle(conversation.getName());
	for(Message message : messages) {
		style.addLine(Html.fromHtml("<b>"+UIHelper.getMessageDisplayName(message)+"</b> "+UIHelper.getMessagePreview(mXmppConnectionService,message).first));
	}
	builder.setContentText(UIHelper.getMessageDisplayName(first)+ ": " +UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first);
	builder.setStyle(style);
	if (notify) {
		builder.setTicker(UIHelper.getMessageDisplayName(last) + ": " + UIHelper.getMessagePreview(mXmppConnectionService,last).first);
	}
}
 
開發者ID:xavierle,項目名稱:messengerxmpp,代碼行數:15,代碼來源:NotificationService.java

示例15: modifyForImage

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForImage(final Builder builder, final UnreadConversation.Builder uBuilder,
                            final Message message, final ArrayList<Message> messages) {
    try {
        final Bitmap bitmap = mXmppConnectionService.getFileBackend()
                .getThumbnail(message, getPixel(288), false);
        final ArrayList<Message> tmp = new ArrayList<>();
        for (final Message msg : messages) {
            if (msg.getType() == Message.TYPE_TEXT
                    && msg.getTransferable() == null) {
                tmp.add(msg);
            }
        }
        final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
        bigPictureStyle.bigPicture(bitmap);
        if (tmp.size() > 0) {
            CharSequence text = getMergedBodies(tmp);
            bigPictureStyle.setSummaryText(text);
            builder.setContentText(text);
        } else {
            builder.setContentText(mXmppConnectionService.getString(
                    R.string.received_x_file,
                    UIHelper.getFileDescriptionString(mXmppConnectionService, message)));
        }
        builder.setStyle(bigPictureStyle);
    } catch (final FileNotFoundException e) {
        modifyForTextOnly(builder, uBuilder, messages);
    }
}
 
開發者ID:kriztan,項目名稱:Pix-Art-Messenger,代碼行數:29,代碼來源:NotificationService.java


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