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


Java NotificationChannel.enableVibration方法代碼示例

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


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

示例1: CreateChannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
public static void CreateChannel(String identifier, String name, String description, int importance, String soundName, int enableLights, int lightColor, int enableVibration, long[] vibrationPattern, String bundle) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
        return;

    channels.add(identifier);

    NotificationManager nm = (NotificationManager) UnityPlayer.currentActivity.getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationChannel channel = new NotificationChannel(identifier, name, importance);
    channel.setDescription(description);
    if (soundName != null) {
        Resources res = UnityPlayer.currentActivity.getResources();
        int id = res.getIdentifier("raw/" + soundName, null, UnityPlayer.currentActivity.getPackageName());
        AudioAttributes audioAttributes = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION).setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).build();
        channel.setSound(Uri.parse("android.resource://" + bundle + "/" + id), audioAttributes);
    }
    channel.enableLights(enableLights == 1);
    channel.setLightColor(lightColor);
    channel.enableVibration(enableVibration == 1);
    if (vibrationPattern == null)
        vibrationPattern = new long[] { 1000L, 1000L };
    channel.setVibrationPattern(vibrationPattern);
    nm.createNotificationChannel(channel);
}
 
開發者ID:Agasper,項目名稱:unity-android-notifications,代碼行數:24,代碼來源:UnityNotificationManager.java

示例2: createMainNotificationChannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
@RequiresApi(Build.VERSION_CODES.O)
public void createMainNotificationChannel(Context c) {
    String id = CHANNEL_ID;
    String name = CHANNEL_NAME;
    String description = CHANNEL_DESCRIPTION;
    int importance = NotificationManager.IMPORTANCE_LOW;
    NotificationChannel mChannel = new NotificationChannel(id, name, importance);
    mChannel.setDescription (description);
    mChannel.enableLights(true);
    mChannel.setLightColor( Color.RED);
    mChannel.enableVibration(true);
    NotificationManager mNotificationManager =
            (NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE);
   // NotificationManager mNotificationManager = c.getSystemService(Context.NOTIFICATION_SERVICE) as android.app.NotificationManager
    mNotificationManager.createNotificationChannel(mChannel);
}
 
開發者ID:smtrz,項目名稱:GPSTracker-Android,代碼行數:17,代碼來源:NotificationClass.java

示例3: getNotificationChannelID

import android.app.NotificationChannel; //導入方法依賴的package包/類
private String getNotificationChannelID() {
    final String channelID = "GoalieChannelID";

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationManager mNotificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        CharSequence name = getString(R.string.app_name);
        String description = getString(R.string.channel_description);
        int importance = NotificationManager.IMPORTANCE_HIGH;

        NotificationChannel mChannel = new NotificationChannel(channelID, name, importance);
        mChannel.setDescription(description);
        mChannel.enableLights(true);
        mChannel.enableVibration(true);
        mNotificationManager.createNotificationChannel(mChannel);
    }

    return channelID;
}
 
開發者ID:Q115,項目名稱:Goalie_Android,代碼行數:21,代碼來源:MessagingService.java

示例4: createNotificationChannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
private void createNotificationChannel() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        String id = Constants.NOTIFICATION_CHANNEL_ID;
        CharSequence name = getString(R.string.notification_channel_name);
        String desc = getString(R.string.notification_channel_desc);
        int importance = NotificationManager.IMPORTANCE_LOW;
        NotificationChannel channel = new NotificationChannel(id, name, importance);
        channel.setShowBadge(false);
        channel.setDescription(desc);
        channel.enableLights(false);
        channel.enableVibration(false);
        manager.createNotificationChannel(channel);
    }

}
 
開發者ID:abhijitvalluri,項目名稱:fitnotifications,代碼行數:17,代碼來源:HomeActivity.java

示例5: createNotificationChannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
public static String createNotificationChannel(@NonNull final Context context) {
	final NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
	if (notificationManager == null) {
		return "";
	}

	final NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_LOW);
	channel.setDescription(CHANNEL_DESCRIPTION);
	channel.enableLights(false);
	channel.enableVibration(false);
	channel.setBypassDnd(false);
	channel.setShowBadge(false);
	channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);

	notificationManager.createNotificationChannel(channel);
	return CHANNEL_ID;
}
 
開發者ID:icapps,項目名稱:niddler,代碼行數:18,代碼來源:OreoCompatHelper.java

示例6: openChannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
/**
 * Creates the {@link NotificationChannel} for devices running Android O or higher
 */
private void openChannel() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, mContext.getResources().getString(R.string.notification_channel_playback), android.app.NotificationManager.IMPORTANCE_LOW);
        // Disable lights & vibration
        channel.enableVibration(false);
        channel.enableLights(false);
        channel.setVibrationPattern(null);

        // Allow lockscreen playback control
        channel.setLockscreenVisibility(android.support.v4.app.NotificationCompat.VISIBILITY_PUBLIC);

        // Register the channel
        mNotificationManager.createNotificationChannel(channel);
    }
}
 
開發者ID:gateship-one,項目名稱:odyssey,代碼行數:19,代碼來源:OdysseyNotificationManager.java

示例7: NotificationUtils

import android.app.NotificationChannel; //導入方法依賴的package包/類
public NotificationUtils(Context context)
{
	mContext = context;
	mManager = NotificationManagerCompat.from(context);
	mDatabase = new AccessDatabase(context);
	mPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);

	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
		NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

		NotificationChannel channelHigh = new NotificationChannel(NOTIFICATION_CHANNEL_HIGH, mContext.getString(R.string.text_appName), NotificationManager.IMPORTANCE_HIGH);
		channelHigh.enableLights(mPreferences.getBoolean("notification_light", false));
		channelHigh.enableVibration(mPreferences.getBoolean("notification_vibrate", false));
		notificationManager.createNotificationChannel(channelHigh);

		NotificationChannel channelLow = new NotificationChannel(NOTIFICATION_CHANNEL_LOW, mContext.getString(R.string.text_appName), NotificationManager.IMPORTANCE_NONE);
		notificationManager.createNotificationChannel(channelLow);
	}
}
 
開發者ID:genonbeta,項目名稱:TrebleShot,代碼行數:20,代碼來源:NotificationUtils.java

示例8: createNotificationChannels

import android.app.NotificationChannel; //導入方法依賴的package包/類
/**
 * Create notification channels required for displayal of notifications on >=API O
 */
@RequiresApi(api = Build.VERSION_CODES.O)
public static void createNotificationChannels(Context context) {
    NotificationManager mNotificationManager =
        (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    String channelId = ApplicationConstants.MEDIA_NOTIFICATION_CHANNEL_ID;
    CharSequence userVisibleChannelName = context.getString(R.string.media_notification_channel_name);
    String userVisibleDescription = context.getString(R.string.media_notification_channel_description);

    int notificationImportance = NotificationManager.IMPORTANCE_DEFAULT;
    AudioAttributes audioAttributes =
        new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build();

    NotificationChannel mediaNotificationChannel = new NotificationChannel(channelId, userVisibleChannelName, notificationImportance);
    mediaNotificationChannel.setDescription(userVisibleDescription);
    mediaNotificationChannel.enableVibration(false);
    mediaNotificationChannel.enableLights(false);
    mediaNotificationChannel.setSound(Uri.EMPTY, audioAttributes);

    mNotificationManager.createNotificationChannel(mediaNotificationChannel);
}
 
開發者ID:ZinoKader,項目名稱:SpotiQ,代碼行數:25,代碼來源:NotificationUtil.java

示例9: initDefaultChannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
private void initDefaultChannel() {
    if (Build.VERSION.SDK_INT < 26) {
        return;
    }
    final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    if (notificationManager == null) {
        return;
    }

    final CharSequence channelName = SoftwareInformation.getAppName(context);
    final int importance = NotificationManager.IMPORTANCE_DEFAULT;
    final NotificationChannel notificationChannel = new NotificationChannel(MM_DEFAULT_CHANNEL_ID, channelName, importance);
    notificationChannel.enableLights(true);
    notificationChannel.enableVibration(true);
    notificationManager.createNotificationChannel(notificationChannel);
}
 
開發者ID:infobip,項目名稱:mobile-messaging-sdk-android,代碼行數:17,代碼來源:MobileMessagingCore.java

示例10: createchannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
private void createchannel() {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
        NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationChannel mChannel = new NotificationChannel(getString(R.string.default_notification_channel_id),
            getString(R.string.channel_name),  //name of the channel
            NotificationManager.IMPORTANCE_DEFAULT);   //importance level
        //important level: default is is high on the phone.  high is urgent on the phone.  low is medium, so none is low?
        // Configure the notification channel.
        mChannel.setDescription(getString(R.string.channel_description));
        mChannel.enableLights(true);
        //Sets the notification light color for notifications posted to this channel, if the device supports this feature.
        mChannel.setLightColor(Color.RED);
        mChannel.enableVibration(true);
        mChannel.setShowBadge(true);
        mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
        nm.createNotificationChannel(mChannel);

    }
}
 
開發者ID:JimSeker,項目名稱:googleplayAPI,代碼行數:20,代碼來源:MainActivity.java

示例11: onCreate

import android.app.NotificationChannel; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        CharSequence name = getString(R.string.channel_name_eta);
        String description = getString(R.string.channel_description_eta);
        NotificationChannel channel = new NotificationChannel(C.NOTIFICATION.CHANNEL_ETA, name, NotificationManager.IMPORTANCE_HIGH);
        channel.setDescription(description);
        channel.enableLights(false);
        channel.enableVibration(false);
        notificationManager.createNotificationChannel(channel);
    }
    disposables.add(RxBroadcastReceiver.create(this, new IntentFilter(C.ACTION.ETA_UPDATE))
            .share()
            .subscribeWith(etaObserver()));
}
 
開發者ID:alvinhkh,項目名稱:buseta,代碼行數:19,代碼來源:EtaJobService.java

示例12: createDefaultNotificationChannelIfNeeded

import android.app.NotificationChannel; //導入方法依賴的package包/類
@TargetApi(26)
private void createDefaultNotificationChannelIfNeeded(JSONObject options) {
  // only call on Android O and above
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    final NotificationManager notificationManager = (NotificationManager) cordova.getActivity()
        .getSystemService(Context.NOTIFICATION_SERVICE);
    List<NotificationChannel> channels = notificationManager.getNotificationChannels();
    if (channels.size() == 0) {
      NotificationChannel mChannel = new NotificationChannel(DEFAULT_CHANNEL_ID, "PhoneGap PushPlugin",
          NotificationManager.IMPORTANCE_DEFAULT);
      mChannel.enableVibration(options.optBoolean(VIBRATE, true));
      mChannel.setShowBadge(true);
      notificationManager.createNotificationChannel(mChannel);
    }
  }
}
 
開發者ID:phonegap,項目名稱:phonegap-plugin-push,代碼行數:17,代碼來源:PushPlugin.java

示例13: createChannels

import android.app.NotificationChannel; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.O)
public void createChannels() {

    NotificationChannel launchImminent = new NotificationChannel(CHANNEL_LAUNCH_IMMINENT,
            CHANNEL_LAUNCH_IMMINENT_NAME, NotificationManager.IMPORTANCE_HIGH);
    launchImminent.enableLights(true);
    launchImminent.setLightColor(ContextCompat.getColor(this, R.color.primary));
    launchImminent.setShowBadge(true);
    launchImminent.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
    getManager().createNotificationChannel(launchImminent);

    NotificationChannel statusChanged = new NotificationChannel(CHANNEL_LAUNCH_UPDATE,
            CHANNEL_LAUNCH_UPDATE_NAME, NotificationManager.IMPORTANCE_DEFAULT);
    statusChanged.enableLights(false);
    statusChanged.enableVibration(true);
    statusChanged.setLightColor(Color.RED);
    statusChanged.setShowBadge(true);
    getManager().createNotificationChannel(statusChanged);

}
 
開發者ID:ItsCalebJones,項目名稱:SpaceLaunchNow-Android,代碼行數:21,代碼來源:NotificationHelper.java

示例14: createchannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
private void createchannel() {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
        NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationChannel mChannel = new NotificationChannel(id,
                getString(R.string.channel_name),  //name of the channel
                NotificationManager.IMPORTANCE_DEFAULT);   //importance level
        //important level: default is is high on the phone.  high is urgent on the phone.  low is medium, so none is low?
        // Configure the notification channel.
        mChannel.setDescription(getString(R.string.channel_description));
        mChannel.enableLights(true);
        // Sets the notification light color for notifications posted to this channel, if the device supports this feature.
        mChannel.setLightColor(Color.RED);
        mChannel.enableVibration(true);
        mChannel.setShowBadge(true);
        mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
        nm.createNotificationChannel(mChannel);

    }
}
 
開發者ID:JimSeker,項目名稱:BroadCastReceiver,代碼行數:20,代碼來源:MainActivity.java

示例15: createchannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
private void createchannel() {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
        NotificationChannel mChannel = new NotificationChannel(id,
                getString(R.string.channel_name),  //name of the channel
                NotificationManager.IMPORTANCE_DEFAULT);   //importance level
        //important level: default is is high on the phone.  high is urgent on the phone.  low is medium, so none is low?
        // Configure the notification channel.
        mChannel.setDescription(getString(R.string.channel_description));
        mChannel.enableLights(true);
        // Sets the notification light color for notifications posted to this channel, if the device supports this feature.
        mChannel.setLightColor(Color.RED);
        mChannel.enableVibration(true);
        mChannel.setShowBadge(true);
        mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
        nm.createNotificationChannel(mChannel);

    }
}
 
開發者ID:JimSeker,項目名稱:BroadCastReceiver,代碼行數:19,代碼來源:MainActivity.java


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