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


Java Builder.setOnlyAlertOnce方法代碼示例

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


在下文中一共展示了Builder.setOnlyAlertOnce方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: getBuilder

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public static Builder getBuilder(Context context, boolean  alert)
{
	Builder builder = new Builder(context).setSmallIcon(R.drawable.ic_notification).setAutoCancel(true);

	if (alert == true)
	{
		int defaults = 0;

		if (KlyphPreferences.getNotificationRingtone() != null && KlyphPreferences.getNotificationRingtone().equals("default"))
		{
			defaults |= android.app.Notification.DEFAULT_SOUND;
		}
		else if (KlyphPreferences.getNotificationRingtoneUri() == null)
		{
			builder.setSound(null);
		}
		else
		{
			builder.setSound(Uri.parse(KlyphPreferences.getNotificationRingtoneUri()));
		}

		if (KlyphPreferences.isNotificationVibrationEnabled() == true)
			defaults |= android.app.Notification.DEFAULT_VIBRATE;

		defaults |= android.app.Notification.DEFAULT_LIGHTS;
		
		builder.setDefaults(defaults);
		builder.setOnlyAlertOnce(true);
	}

	return builder;
}
 
開發者ID:jonathangerbaud,項目名稱:Klyph,代碼行數:33,代碼來源:KlyphNotification.java

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


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