本文整理匯總了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());
}
示例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;
}
示例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();
}
}
示例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());
}
}
示例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());
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
});
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}