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


Java Builder.setContentTitle方法代碼示例

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


在下文中一共展示了Builder.setContentTitle方法的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: 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());
		final Message message;
		if ((message = getImage(messages)) != null) {
			modifyForImage(mBuilder, message, messages, notify);
		} else {
			modifyForTextOnly(mBuilder, messages, notify);
		}
		mBuilder.setContentIntent(createContentIntent(conversation
					.getUuid()));
	}
	return mBuilder;
}
 
開發者ID:juanignaciomolina,項目名稱:txtr,代碼行數:21,代碼來源:NotificationService.java

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: handleBuildConnectionStatusChange

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void handleBuildConnectionStatusChange(final int status, final Intent intentToRun) {
	final Builder notifyBuilder = new Builder(this);
	notifyBuilder.setContentTitle(getText(R.string.title_svc_connecting_to_server));
	switch (status) {
	case BuildingSessionConnectionStatus.GettingLibrary:
		notifyBuilder.setContentText(getText(R.string.lbl_getting_library_details));
		break;
	case BuildingSessionConnectionStatus.GettingLibraryFailed:
		Toast.makeText(this, PlaybackService.this.getText(R.string.lbl_please_connect_to_valid_server), Toast.LENGTH_SHORT).show();
		stopSelf(startId);
		return;
	case BuildingSessionConnectionStatus.BuildingConnection:
		notifyBuilder.setContentText(getText(R.string.lbl_connecting_to_server_library));
		break;
	case BuildingSessionConnectionStatus.BuildingConnectionFailed:
		Toast.makeText(this, PlaybackService.this.getText(R.string.lbl_error_connecting_try_again), Toast.LENGTH_SHORT).show();
		stopSelf(startId);
		return;
	case BuildingSessionConnectionStatus.GettingView:
		notifyBuilder.setContentText(getText(R.string.lbl_getting_library_views));
		break;
	case BuildingSessionConnectionStatus.GettingViewFailed:
		Toast.makeText(this, PlaybackService.this.getText(R.string.lbl_library_no_views), Toast.LENGTH_SHORT).show();
		stopSelf(startId);
		return;
	case BuildingSessionConnectionStatus.BuildingSessionComplete:
		stopNotification();

		lazyLibraryRepository.getObject()
			.getLibrary(lazyChosenLibraryIdentifierProvider.getObject().getSelectedLibraryId())
			.then(this::initializePlaybackPlaylistStateManager)
			.then(perform(m -> actOnIntent(intentToRun)))
			.excuse(UnhandledRejectionHandler);

		localBroadcastManagerLazy.getObject().registerReceiver(onLibraryChanged, new IntentFilter(BrowserLibrarySelection.libraryChosenEvent));

		return;
	}
	notifyNotificationManager(notifyBuilder);
}
 
開發者ID:danrien,項目名稱:projectBlue,代碼行數:41,代碼來源:PlaybackService.java

示例9: Notification

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void Notification(PushNotification noti, Context context) {
        NotificationDBProvider dbProvider = NotificationDBProvider.getInstance(context);
        PendingIntent pendingIntent = getPendingIntent(context, DummyActivity.class);

        ArrayList<String> messages = dbProvider.getUnReadMessageTitle6();
        int count = dbProvider.getUnReadMessageCount();
        Builder builder = new NotificationCompat.Builder(context);
        if (count > 1) {
            if (count > 9999) {
                builder.setContentTitle("9999+" + context.getString(R.string.new_notification));
            } else {
                builder.setContentTitle(String.valueOf(count) + context.getString(R.string.new_notification));
            }
            InboxStyle style = new InboxStyle(builder);
            if (count > messages.size()) {
                count = messages.size();
            }
            for (int i = 0; i < count; i++) {
                style.addLine(messages.get(i));
            }
//			style.setSummaryText("+ more");
            builder.setStyle(style);
        } else {
            builder.setContentTitle(noti.title);
            builder.setContentText(noti.message);
        }
        commonBuilder(builder, pendingIntent, noti.message);
        NotificationManager notifyManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        notifyManager.notify(0, builder.build());

        Intent intentBoradCast = new Intent(Setting.BROADCAST_ALARM_UPDATE);
        LocalBroadcastManager.getInstance(context).sendBroadcast(intentBoradCast);
    }
 
開發者ID:BioStar2,項目名稱:BioStar2Android,代碼行數:34,代碼來源:GcmBroadcastReceiver.java

示例10: sendNotification

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void sendNotification(final Notification notification, final boolean  sendDetails)
{
	final Builder builder = KlyphNotification.getBuilder(service.get(), true);
	
	builder.setContentTitle(notification.getSender_name());
	builder.setContentText(notification.getTitle_text());
	builder.setTicker(String.format("%1$s\n%2$s", notification.getSender_name(), notification.getTitle_text()));
	
	ImageLoader.loadImage(notification.getSender_pic(), new SimpleFakeImageLoaderListener() {

		@Override
		public void onBitmapFailed(Drawable drawable)
		{
			if (sendDetails)
				KlyphNotification.sendNotification(service.get(), builder, notification);
			else
				KlyphNotification.sendNotification(service.get(), builder);
		}

		@Override
		public void onBitmapLoaded(Bitmap bitmap, LoadedFrom arg1)
		{
			builder.setLargeIcon(bitmap);
			if (sendDetails)
				KlyphNotification.sendNotification(service.get(), builder, notification);
			else
				KlyphNotification.sendNotification(service.get(), builder);
		}
	});
}
 
開發者ID:jonathangerbaud,項目名稱:Klyph,代碼行數:31,代碼來源:NotificationService.java

示例11: SpeedWaveNotificationManager

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public SpeedWaveNotificationManager(Builder builder,
		NotificationManager notificationManager, IngressIntentBuilder intentBuilder) {
	this.builder = builder.setContentTitle("Ingress SpeedWave");
	this.ingressIntent = intentBuilder.build();
	this.notificationManager = notificationManager;
	
	this.showInitialNotification();
}
 
開發者ID:miffels,項目名稱:ingress-speedwave,代碼行數:9,代碼來源:SpeedWaveNotificationManager.java

示例12: 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:Frozenbox,項目名稱:frozenchat,代碼行數:40,代碼來源:NotificationService.java

示例13: buildMultipleConversation

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildMultipleConversation() {
	final Builder mBuilder = new NotificationCompat.Builder(
			mXmppConnectionService);
	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 (ArrayList<Message> messages : notifications.values()) {
		if (messages.size() > 0) {
			conversation = messages.get(0).getConversation();
			String name = conversation.getName();
			style.addLine(Html.fromHtml("<b>" + name + "</b> "
						+ getReadableBody(messages.get(0))));
			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
					.getUuid()));
	}
	return mBuilder;
}
 
開發者ID:juanignaciomolina,項目名稱:txtr,代碼行數:36,代碼來源:NotificationService.java

示例14: showInNotificationBar

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void showInNotificationBar(String title,String ticker, Bitmap iconBitmap,int notificationId,Intent intent) {
	logger.d("notification#showInNotificationBar title:%s ticker:%s",title,ticker);

	NotificationManager notifyMgr = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
	if (notifyMgr == null) {
		return;
	}

	Builder builder = new NotificationCompat.Builder(ctx);
	builder.setContentTitle(title);
	builder.setContentText(ticker);
	builder.setSmallIcon(R.drawable.tt_small_icon);
	builder.setTicker(ticker);
	builder.setWhen(System.currentTimeMillis());
	builder.setAutoCancel(true);

	// this is the content near the right bottom side
	// builder.setContentInfo("content info");

	if (configurationSp.getCfg(SysConstant.SETTING_GLOBAL,ConfigurationSp.CfgDimension.VIBRATION)) {
		// delay 0ms, vibrate 200ms, delay 250ms, vibrate 200ms
		long[] vibrate = {0, 200, 250, 200};
		builder.setVibrate(vibrate);
	} else {
		logger.d("notification#setting is not using vibration");
	}

	// sound
	if (configurationSp.getCfg(SysConstant.SETTING_GLOBAL,ConfigurationSp.CfgDimension.SOUND)) {
		builder.setDefaults(Notification.DEFAULT_SOUND);
	} else {
		logger.d("notification#setting is not using sound");
	}
	if (iconBitmap != null) {
		logger.d("notification#fetch icon from network ok");
		builder.setLargeIcon(iconBitmap);
	} else {
           // do nothint ?
	}
	// if MessageActivity is in the background, the system would bring it to
	// the front
	intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
	PendingIntent pendingIntent = PendingIntent.getActivity(ctx, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT);
	builder.setContentIntent(pendingIntent);
	Notification notification = builder.build();
	notifyMgr.notify(notificationId, notification);
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:48,代碼來源:IMNotificationManager.java

示例15: 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


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