本文整理匯總了Java中android.support.v4.app.NotificationCompat.Builder.setWhen方法的典型用法代碼示例。如果您正苦於以下問題:Java Builder.setWhen方法的具體用法?Java Builder.setWhen怎麽用?Java Builder.setWhen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.app.NotificationCompat.Builder
的用法示例。
在下文中一共展示了Builder.setWhen方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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();
}
}
示例3: 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());
}
}
示例4: 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);
}
示例5: 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);
}
示例6: 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;
}
示例7: 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;
}