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


Java Builder.setContentIntent方法代碼示例

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


在下文中一共展示了Builder.setContentIntent方法的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: onConnectionFailed

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
@Override
public void onConnectionFailed() {
	Builder builder = new NotificationCompat.Builder(this);
	builder.setSmallIcon(R.drawable.ic_launcher)
			.setContentTitle("Connection failed")
			.setContentText("Permissions need to be granted first");

	Intent intent = new Intent(this, MainActivity.class);
	intent.putExtra(MainActivity.EXTRA_KEY_REAUTHORIZE, true);

	TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
	stackBuilder.addParentStack(MainActivity.class);
	stackBuilder.addNextIntent(intent);
	PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
			PendingIntent.FLAG_UPDATE_CURRENT);

	builder.setContentIntent(resultPendingIntent);

	NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
	notificationManager.notify(42, builder.build());

	stopSelf();
}
 
開發者ID:nickglobal,項目名稱:TvPoo,代碼行數:24,代碼來源:ConnectionService.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: 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

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

示例7: commonBuilder

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void commonBuilder(Builder builder, PendingIntent intent, String ticker) {
        long[] pattern = {500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500};
        Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        builder.setSmallIcon(R.drawable.ic_launcher);
        builder.setContentIntent(intent);
        builder.setSound(alarmSound);
        builder.setLights(Color.BLUE, 500, 500);
        builder.setVibrate(pattern);
//        builder.setTicker(ticker);
        builder.setAutoCancel(true);
        builder.setPriority(NotificationCompat.PRIORITY_MAX);
    }
 
開發者ID:BioStar2,項目名稱:BioStar2Android,代碼行數:13,代碼來源:GcmBroadcastReceiver.java

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

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

示例10: notifyRegisteredAccounts

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public synchronized void notifyRegisteredAccounts(ArrayList<SipProfileState> activeAccountsInfos, boolean showNumbers) {
	if (!isServiceWrapper) {
		Log.e(THIS_FILE, "Trying to create a service notification from outside the service");
		return;
	}
	int icon = R.drawable.ic_stat_sipok;
	CharSequence tickerText = context.getString(R.string.service_ticker_registered_text);
	long when = System.currentTimeMillis();
	

       Builder nb = new Builder(context);
       nb.setSmallIcon(icon);
       nb.setTicker(tickerText);
       nb.setWhen(when);
	Intent notificationIntent = new Intent(SipManager.ACTION_SIP_DIALER);
	notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
	PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
	
	RegistrationNotification contentView = new RegistrationNotification(context.getPackageName());
	contentView.clearRegistrations();
	if(!Compatibility.isCompatible(9)) {
	    contentView.setTextsColor(notificationPrimaryTextColor);
	}
	contentView.addAccountInfos(context, activeAccountsInfos);

	// notification.setLatestEventInfo(context, contentTitle,
	// contentText, contentIntent);
	nb.setOngoing(true);
	nb.setOnlyAlertOnce(true);
       nb.setContentIntent(contentIntent);
       nb.setContent(contentView);
	
	Notification notification = nb.build();
	notification.flags |= Notification.FLAG_NO_CLEAR;
	// We have to re-write content view because getNotification setLatestEventInfo implicitly
       notification.contentView = contentView;
	if (showNumbers) {
           // This only affects android 2.3 and lower
           notification.number = activeAccountsInfos.size();
       }
	startForegroundCompat(REGISTER_NOTIF_ID, notification);
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:43,代碼來源:SipNotifications.java

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

示例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();
			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

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

示例14: updateNotificationWithError

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public void updateNotificationWithError(String mErrorMessage, boolean isMediaError, boolean isPage,
                                        boolean isVideoPressError) {
    AppLog.d(T.POSTS, "updateNotificationWithError: " + mErrorMessage);

    Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext());
    String postOrPage = (String) (isPage ? mContext.getResources().getText(R.string.page_id)
            : mContext.getResources().getText(R.string.post_id));
    Intent notificationIntent = new Intent(mContext, isPage ? PagesActivity.class : PostsActivity.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
            | Intent.FLAG_ACTIVITY_NEW_TASK
            | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    notificationIntent.putExtra(PostsActivity.EXTRA_VIEW_PAGES, isPage);
    notificationIntent.putExtra(PostsActivity.EXTRA_ERROR_MSG, mErrorMessage);
    if (isVideoPressError) {
        notificationIntent.putExtra(PostsActivity.EXTRA_ERROR_INFO_TITLE, getString(R.string.learn_more));
        notificationIntent.putExtra(PostsActivity.EXTRA_ERROR_INFO_LINK, Constants.videoPressURL);
    }
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0,
            notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    String errorText = mContext.getResources().getText(R.string.upload_failed).toString();
    if (isMediaError) {
        errorText = mContext.getResources().getText(R.string.media) + " "
                + mContext.getResources().getText(R.string.error);
    }

    notificationBuilder.setSmallIcon(android.R.drawable.stat_notify_error);
    notificationBuilder.setContentTitle((isMediaError) ? errorText :
            mContext.getResources().getText(R.string.upload_failed));
    notificationBuilder.setContentText((isMediaError) ? mErrorMessage : postOrPage + " " + errorText
            + ": " + mErrorMessage);
    notificationBuilder.setContentIntent(pendingIntent);
    notificationBuilder.setAutoCancel(true);
    if (mNotificationErrorId == 0) {
        mNotificationErrorId = mNotificationId + (new Random()).nextInt();
    }
    mNotificationManager.notify(mNotificationErrorId, notificationBuilder.build());
}
 
開發者ID:ldsddn,項目名稱:wordpress_app_android,代碼行數:42,代碼來源:PostUploadService.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:kriztan,項目名稱:Pix-Art-Messenger,代碼行數:48,代碼來源:NotificationService.java


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