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


Java Builder.setCategory方法代碼示例

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


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

示例1: modifyForSoundVibrationAndLight

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForSoundVibrationAndLight(Builder mBuilder, boolean notify, SharedPreferences preferences) {
    final Resources resources = mXmppConnectionService.getResources();
    final String ringtone = preferences.getString("notification_ringtone", resources.getString(R.string.notification_ringtone));
    final boolean vibrate = preferences.getBoolean("vibrate_on_notification", resources.getBoolean(R.bool.vibrate_on_notification));
    final boolean led = preferences.getBoolean("led", resources.getBoolean(R.bool.led));
    final boolean headsup = preferences.getBoolean("notification_headsup", resources.getBoolean(R.bool.headsup_notifications));
    if (notify && !isQuietHours()) {
        if (vibrate) {
            final int dat = 70;
            final long[] pattern = {0, 3 * dat, dat, dat};
            mBuilder.setVibrate(pattern);
        } else {
            mBuilder.setVibrate(new long[]{0});
        }
        Uri uri = Uri.parse(ringtone);
        try {
            mBuilder.setSound(fixRingtoneUri(uri));
        } catch (SecurityException e) {
            Log.d(Config.LOGTAG, "unable to use custom notification sound " + uri.toString());
        }
    }
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mBuilder.setCategory(Notification.CATEGORY_MESSAGE);
    }
    mBuilder.setPriority(notify ? (headsup ? NotificationCompat.PRIORITY_HIGH : NotificationCompat.PRIORITY_DEFAULT) : NotificationCompat.PRIORITY_LOW);
    setNotificationColor(mBuilder);
    mBuilder.setDefaults(0);
    if (led) {
        mBuilder.setLights(0xff0080FF, 2000, 3000);
    }
}
 
開發者ID:kriztan,項目名稱:Pix-Art-Messenger,代碼行數:32,代碼來源:NotificationService.java

示例2: modifyForSoundVibrationAndLight

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForSoundVibrationAndLight(Builder mBuilder, boolean notify, SharedPreferences preferences) {
	final Resources resources = mXmppConnectionService.getResources();
	final String ringtone = preferences.getString("notification_ringtone", resources.getString(R.string.notification_ringtone));
	final boolean vibrate = preferences.getBoolean("vibrate_on_notification", resources.getBoolean(R.bool.vibrate_on_notification));
	final boolean led = preferences.getBoolean("led", resources.getBoolean(R.bool.led));
	final boolean headsup = preferences.getBoolean("notification_headsup", resources.getBoolean(R.bool.headsup_notifications));
	if (notify && !isQuietHours()) {
		if (vibrate) {
			final int dat = 70;
			final long[] pattern = {0, 3 * dat, dat, dat};
			mBuilder.setVibrate(pattern);
		} else {
			mBuilder.setVibrate(new long[]{0});
		}
		Uri uri = Uri.parse(ringtone);
		try {
			mBuilder.setSound(fixRingtoneUri(uri));
		} catch (SecurityException e) {
			Log.d(Config.LOGTAG,"unable to use custom notification sound "+uri.toString());
		}
	}
	if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		mBuilder.setCategory(Notification.CATEGORY_MESSAGE);
	}
	mBuilder.setPriority(notify ? (headsup ? NotificationCompat.PRIORITY_HIGH : NotificationCompat.PRIORITY_DEFAULT) : NotificationCompat.PRIORITY_LOW);
	setNotificationColor(mBuilder);
	mBuilder.setDefaults(0);
	if (led) {
		mBuilder.setLights(0xff00FF00, 2000, 3000);
	}
}
 
開發者ID:syntafin,項目名稱:TenguChat,代碼行數:32,代碼來源:NotificationService.java

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


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