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


Java Builder.build方法代碼示例

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


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

示例1: buildSummary

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public Notification buildSummary(Context context, NotificationManager manager, String group, List<NotificationMessage> messages) {
    NotificationCompat.WearableExtender extender = new NotificationCompat.WearableExtender();

    Intent intent = new Intent(context, NotificationIntentService.class);
    manager.setCancelAll(intent, group);
    intent.setData(Uri.parse("nuclei://notifications?_g=" + group));
    PendingIntent pendingIntent = PendingIntent.getService(context, getDeleteIntentRequestId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);

    Builder builder = new Builder(context)
            .setSmallIcon(manager.getDefaultSmallIcon())
            .setLargeIcon(manager.getDefaultLargeIcon())
            .setAutoCancel(true)
            .setGroup(group)
            .setGroupSummary(true);

    onBuildSummary(context, manager, builder, extender, group, messages);

    builder.setDeleteIntent(pendingIntent);

    extender.extend(builder);

    return builder.build();
}
 
開發者ID:lifechurch,項目名稱:nuclei-android,代碼行數:24,代碼來源:NotificationBuilder.java

示例2: buildNotification

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public Notification buildNotification(Context context, NotificationManager manager, NotificationMessage message, List<NotificationMessage> messages) {
    NotificationCompat.WearableExtender extender = new NotificationCompat.WearableExtender();

    Intent intent = new Intent(context, NotificationIntentService.class);
    manager.setCancelMessage(intent, message);
    intent.setData(Uri.parse("nuclei://notifications?_id=" + message._id + "&_g=" + message.groupKey));
    PendingIntent pendingIntent = PendingIntent.getService(context, getDeleteIntentRequestId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);

    Builder builder = new Builder(context)
            .setSmallIcon(manager.getDefaultSmallIcon())
            .setLargeIcon(manager.getDefaultLargeIcon())
            .setOngoing(false)
            .setAutoCancel(true);

    if (messages.size() > 1) {
        builder.setGroup(message.groupKey).setGroupSummary(false);
    }

    onBuildNotification(context, manager, builder, extender, message);

    builder.setDeleteIntent(pendingIntent);

    extender.extend(builder);

    return builder.build();
}
 
開發者ID:lifechurch,項目名稱:nuclei-android,代碼行數:27,代碼來源:NotificationBuilder.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: 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

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

示例6: build

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
@Override
public Notification build() {

    Builder builder = new Builder(context)
            .setOngoing(isOngoing)
            .setSmallIcon(drawable.ic_assistance_service)
            .setContentTitle(context.getText(string.service_running_notification_title))
            .setContentText(context.getText(string.service_running_notification_text))
            .setGroup(Config.DEFAULT_NOTIFICATION_GROUP)
            .setGroupSummary(isSummaryForGroup);

    builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), drawable.kraki_big));

    return builder.build();
}
 
開發者ID:Telecooperation,項目名稱:assistance-platform-client-sdk-android,代碼行數:16,代碼來源:ServiceNotificationCreator.java

示例7: notifcation

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
/**
 * Displays a notification in the notification area of the UI
 * @param context Context from which to create the notification
 * @param messageString The string to display to the user as a message
 * @param intent The intent which will start the activity when the user clicks the notification
 * @param notificationTitle The resource reference to the notification title
 */
static void notifcation(Context context, String messageString, Intent intent, int notificationTitle) {

  //Get the notification manage which we will use to display the notification
  String ns = Context.NOTIFICATION_SERVICE;
  NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);

  long when = System.currentTimeMillis();

  //get the notification title from the application's strings.xml file
  CharSequence contentTitle = context.getString(notificationTitle);

  //the message that will be displayed as the ticker
  String ticker = contentTitle + " " + messageString;

  //build the pending intent that will start the appropriate activity
  PendingIntent pendingIntent = PendingIntent.getActivity(context,
          0, intent, 0);

  //build the notification
  Builder notificationCompat = new Builder(context);
  notificationCompat.setAutoCancel(true)
      .setContentTitle(contentTitle)
      .setContentIntent(pendingIntent)
      .setContentText(messageString)
      .setTicker(ticker)
      .setWhen(when)
      .setSmallIcon(R.mipmap.ic_launcher);

  Notification notification = notificationCompat.build();
  //display the notification
  mNotificationManager.notify(MessageID, notification);
  MessageID++;

}
 
開發者ID:Cirrus-Link,項目名稱:Sparkplug,代碼行數:42,代碼來源:Notify.java

示例8: updateNotification

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void updateNotification(final boolean notify) {
	final NotificationManager notificationManager = (NotificationManager) mXmppConnectionService
		.getSystemService(Context.NOTIFICATION_SERVICE);
	final SharedPreferences preferences = mXmppConnectionService.getPreferences();

	final String ringtone = preferences.getString("notification_ringtone", null);
	final boolean vibrate = preferences.getBoolean("vibrate_on_notification", true);

	if (notifications.size() == 0) {
		notificationManager.cancel(NOTIFICATION_ID);
	} else {
		if (notify) {
			this.markLastNotification();
		}
		final Builder mBuilder;
		if (notifications.size() == 1) {
			mBuilder = buildSingleConversations(notify);
		} else {
			mBuilder = buildMultipleConversation();
		}
		if (notify && !isQuietHours()) {
			if (vibrate) {
				final int dat = 70;
				final long[] pattern = {0, 3 * dat, dat, dat};
				mBuilder.setVibrate(pattern);
			}
			if (ringtone != null) {
				mBuilder.setSound(Uri.parse(ringtone));
			}
		}
		mBuilder.setSmallIcon(R.drawable.ic_notification);
		mBuilder.setDeleteIntent(createDeleteIntent());
		mBuilder.setLights(0xffffffff, 2000, 4000);
		final Notification notification = mBuilder.build();
		notificationManager.notify(NOTIFICATION_ID, notification);
	}
}
 
開發者ID:juanignaciomolina,項目名稱:txtr,代碼行數:38,代碼來源:NotificationService.java

示例9: notify

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public static void notify(Context ctx, String title, String subTitle, Parcelable params) {
	NOTIFICATION_ID = NOTIFICATION_ID % NOFICATION_COUNT + 1;
	// Log.i(TAG, "NOTIFICATION_ID:" + NOTIFICATION_ID);
	NotificationManager manager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
	Intent intent = ctx.getPackageManager().getLaunchIntentForPackage(ctx.getPackageName());
	PendingIntent contentIntent = PendingIntent.getActivity(ctx, NOTIFICATION_ID, intent,
			PendingIntent.FLAG_UPDATE_CURRENT);
	Builder builder = new Builder(ctx);
	builder.setSmallIcon(R.drawable.icon).setTicker(title).setAutoCancel(true).setContentTitle(title)
			.setContentText(subTitle).setContentIntent(contentIntent);
	Notification notif = builder.build();
	notif.defaults = Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE;
	notif.number = NOTIFICATION_ID;
	manager.notify(NOTIFICATION_ID, notif);
}
 
開發者ID:qianweicheng,項目名稱:Qmusic,代碼行數:16,代碼來源:BNotification.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: notifcation

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
/**
   * Displays a notification in the notification area of the UI
   * @param context Context from which to create the notification
   * @param messageString The string to display to the user as a message
   * @param smallIconId drawable id
   * @param intent The intent which will start the activity when the user clicks the notification
   * @param notificationTitle The resource reference to the notification title
   * @return messageID
   */
  public static int notifcation(Context context, String messageString,int smallIconId, Intent intent, int notificationTitle) {

    //Get the notification manage which we will use to display the notification
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);

    Calendar.getInstance().getTime().toString();

    long when = System.currentTimeMillis();

    //get the notification title from the application's strings.xml file
    CharSequence contentTitle = context.getString(notificationTitle);

    //the message that will be displayed as the ticker
    String ticker = contentTitle + " " + messageString;

    //build the pending intent that will start the appropriate activity
    PendingIntent pendingIntent = PendingIntent.getActivity(context,
            3, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    //build the notification
    Builder notificationCompat = new Builder(context);
    notificationCompat.setAutoCancel(true)
        .setContentTitle(contentTitle)
        .setContentIntent(pendingIntent)
        .setContentText(messageString)
        .setTicker(ticker)
        .setWhen(when)
        .setSmallIcon(smallIconId)

    ;

    Notification notification = notificationCompat.build();
//    notification.defaults |= Notification.DEFAULT_ALL;
    notification.defaults = Notification.DEFAULT_ALL;
    //display the notification
    mNotificationManager.notify(MessageID, notification);
    return MessageID++;

  }
 
開發者ID:niyueming,項目名稱:NApply,代碼行數:50,代碼來源:Notify.java

示例13: updateNotification

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public void updateNotification(final boolean notify) {
	final NotificationManager notificationManager = (NotificationManager) mXmppConnectionService
			.getSystemService(Context.NOTIFICATION_SERVICE);
	final SharedPreferences preferences = mXmppConnectionService.getPreferences();

	final String ringtone = preferences.getString("notification_ringtone", null);
	final boolean vibrate = preferences.getBoolean("vibrate_on_notification", true);

	if (notifications.size() == 0) {
		notificationManager.cancel(NOTIFICATION_ID);
	} else {
		if (notify) {
			this.markLastNotification();
		}
		final Builder mBuilder;
		if (notifications.size() == 1) {
			mBuilder = buildSingleConversations(notify);
		} else {
			mBuilder = buildMultipleConversation();
		}
		if (notify && !isQuietHours()) {
			if (vibrate) {
				final int dat = 70;
				final long[] pattern = {0, 3 * dat, dat, dat};
				mBuilder.setVibrate(pattern);
			}
			if (ringtone != null) {
				mBuilder.setSound(Uri.parse(ringtone));
			}
		}
		if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
			mBuilder.setCategory(Notification.CATEGORY_MESSAGE);
		}
		setNotificationColor(mBuilder);
		mBuilder.setDefaults(0);
		mBuilder.setSmallIcon(R.drawable.ic_notification);
		mBuilder.setDeleteIntent(createDeleteIntent());
		mBuilder.setLights(0xff00FF00, 2000, 3000);
		final Notification notification = mBuilder.build();
		notificationManager.notify(NOTIFICATION_ID, notification);
	}
}
 
開發者ID:xavierle,項目名稱:messengerxmpp,代碼行數:43,代碼來源:NotificationService.java

示例14: setAlarm

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void setAlarm(long interval, boolean repeat) {
	AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
	Intent intent = new Intent(ACTION_KEEP_ALIVE);
	intent.setClass(mContext, LoginService.class);
	PendingIntent pi = PendingIntent.getService(mContext, REQUEST_CODE
			, intent
			, PendingIntent.FLAG_CANCEL_CURRENT);
	long next = System.currentTimeMillis() + interval + 1000;
	if (repeat) {
		am.setRepeating(AlarmManager.RTC_WAKEUP, next, REPEAT_FREQ, pi);
		// if show notification is enabled, show it
		if (SettingsManager.getBoolean(mContext, SettingsManager.SHOW_NOTIF
				, true)) {
			long now = System.currentTimeMillis();
			int limit = SettingsManager.getInt(mContext
					, SettingsManager.KEEP_ALIVE, -1);
			long login = SettingsManager.getLong(mContext
					, SettingsManager.LOG_IN_TIME, now);

			NotificationManager nm = (NotificationManager) getSystemService(
					NOTIFICATION_SERVICE);
			Builder b = new NotificationCompat.Builder(mContext);
			b.setOngoing(true);
			b.setContentTitle(getResources().getString(R.string.app_name));
			b.setContentText(getResources().getString(R.string.from)
					+ " : " + sdf.format(new Date(login))
					+ (limit <= 0 ? "" : " | " + getResources().getString(R
							.string.upto) + " : " + sdf.format(new Date(login
									+ limit * DateUtils.HOUR_IN_MILLIS))));
			b.setSmallIcon(R.drawable.ic_launcher);
			b.setTicker(getResources().getString(R.string.logged_in)
					+ ", " + getResources().getString(R.string.internet_access));
			Intent i = new Intent(mContext, CredentialActivity.class);
			PendingIntent pia = PendingIntent.getActivity(mContext, 0, i, Intent
					.FLAG_ACTIVITY_CLEAR_TOP);
			b.setContentIntent(pia);
			Notification n = b.build();
			nm.notify(1000, n);
		}
	} else {
		am.set(AlarmManager.RTC_WAKEUP, next, pi);
	}
}
 
開發者ID:ridhishguhan,項目名稱:asianet-autologin,代碼行數:44,代碼來源:LoginService.java


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