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


Java NotificationChannel.setVibrationPattern方法代碼示例

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


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

示例1: createNotificationChannelForAndroidO

import android.app.NotificationChannel; //導入方法依賴的package包/類
private void createNotificationChannelForAndroidO() {
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && mNotificationManager != null) {
        NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,
                "Nova Music Player", NotificationManager.IMPORTANCE_LOW);

        // Configure the notification channel.
        notificationChannel.setDescription("Channel of Nova Music Player");
        notificationChannel.enableLights(false);
        notificationChannel.setLightColor(Color.RED);
        notificationChannel.setVibrationPattern(new long[]{0, 1000, 500, 1000});
        notificationChannel.setSound(null, null);
        notificationChannel.enableVibration(false);
        notificationChannel.setShowBadge(false);
        mNotificationManager.createNotificationChannel(notificationChannel);
    }
}
 
開發者ID:Jaysaw,項目名稱:NovaMusicPlayer,代碼行數:17,代碼來源:NovaNotificationManager.java

示例2: createChannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
@RequiresApi(Build.VERSION_CODES.O)
private void createChannel() {
    if (mNotificationManager.getNotificationChannel(CHANNEL_ID) == null) {
        // The user-visible name of the channel.
        CharSequence name = "MediaSession";
        // The user-visible description of the channel.
        String description = "MediaSession and MediaPlayer";
        int importance = NotificationManager.IMPORTANCE_LOW;
        NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, importance);
        // Configure the notification channel.
        mChannel.setDescription(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.setVibrationPattern(
                new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
        mNotificationManager.createNotificationChannel(mChannel);
        Log.d(TAG, "createChannel: New channel created");
    } else {
        Log.d(TAG, "createChannel: Existing channel reused");
    }
}
 
開發者ID:nazmulidris,項目名稱:mediasession-mediaplayer,代碼行數:25,代碼來源:MediaNotificationManager.java

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

示例4: 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, mService.getResources().getString(R.string.notification_channel_name_playback), android.app.NotificationManager.IMPORTANCE_LOW);
        // Disable lights & vibration
        channel.enableVibration(false);
        channel.enableLights(false);
        channel.setVibrationPattern(null);

        // Allow lockscreen playback control
        channel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PUBLIC);

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

示例5: createNotificationChannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.O)
void createNotificationChannel(Context context) {
    NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    CharSequence name = MobiComKitConstants.PUSH_NOTIFICATION_NAME;
    ;
    int importance = NotificationManager.IMPORTANCE_HIGH;
    if (mNotificationManager.getNotificationChannel(MobiComKitConstants.AL_PUSH_NOTIFICATION) == null) {
        NotificationChannel mChannel = new NotificationChannel(MobiComKitConstants.AL_PUSH_NOTIFICATION, name, importance);
        mChannel.enableLights(true);
        mChannel.setLightColor(Color.GREEN);
        if (ApplozicClient.getInstance(context).isUnreadCountBadgeEnabled()) {
            mChannel.setShowBadge(true);
        } else {
            mChannel.setShowBadge(false);
        }
        if (ApplozicClient.getInstance(context).getVibrationOnNotification()) {
            mChannel.enableVibration(true);
            mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
        }
        AudioAttributes audioAttributes = new AudioAttributes.Builder()
                .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
                .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE).build();
        mChannel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION), audioAttributes);
        mNotificationManager.createNotificationChannel(mChannel);

    }

}
 
開發者ID:AppLozic,項目名稱:Applozic-Android-Chat-Sample,代碼行數:29,代碼來源:RegisterUserClientService.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: 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

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

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

示例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(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,項目名稱:wearable,代碼行數:20,代碼來源:MainActivity.java

示例11: createChannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
private void createChannel(String id, String name, String description) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel mChannel = new NotificationChannel(id, name,
                NotificationManager.IMPORTANCE_HIGH);
        mChannel.setDescription(description);
        mChannel.enableLights(true);
        mChannel.setLightColor(Color.RED);
        mChannel.enableVibration(true);
        mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 100});
        notificationManager.createNotificationChannel(mChannel);
    }
}
 
開發者ID:bsautermeister,項目名稱:GeoFencer,代碼行數:13,代碼來源:SimpleNotification.java

示例12: openChannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
private void openChannel() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, this.getResources().getString(R.string.notification_channel_name_bulk_download), android.app.NotificationManager.IMPORTANCE_LOW);
        // Disable lights & vibration
        channel.enableVibration(false);
        channel.enableLights(false);
        channel.setVibrationPattern(null);

        // Allow lockscreen playback control
        channel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PRIVATE);

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

示例13: setupNotification

import android.app.NotificationChannel; //導入方法依賴的package包/類
private void setupNotification() {
    final Intent i = new Intent(this, MainActivity.class);
    i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            Intent.FLAG_ACTIVITY_CLEAR_TASK);
    final PendingIntent pI;
    pI = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_ONE_SHOT);
    final NotificationManager nM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    final Notification.Builder b = new Notification.Builder(this)
            .setContentTitle("ABCore is running")
            .setContentIntent(pI)
            .setContentText(String.format("Version %s", Packages.CORE_V))
            .setSmallIcon(R.drawable.ic_info_black_24dp)
            .setOngoing(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        final int importance = NotificationManager.IMPORTANCE_LOW;

        final NotificationChannel mChannel = new NotificationChannel("channel_00", "ABCore", importance);
        mChannel.setDescription(String.format("Version %s", Packages.CORE_V));
        mChannel.enableLights(true);
        mChannel.enableVibration(true);
        mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
        nM.createNotificationChannel(mChannel);
        b.setChannelId("channel_00");
    }


    final Notification n = b.build();

    nM.notify(NOTIFICATION_ID, n);

    final Intent broadcastIntent = new Intent();
    broadcastIntent.setAction(MainActivity.RPCResponseReceiver.ACTION_RESP);
    broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
    broadcastIntent.putExtra(PARAM_OUT_MSG, "OK");
    sendBroadcast(broadcastIntent);
}
 
開發者ID:greenaddress,項目名稱:abcore,代碼行數:39,代碼來源:ABCoreService.java

示例14: getChannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.O)
private NotificationChannel getChannel(String id, String name, String description) {
    int importance = NotificationManager.IMPORTANCE_HIGH;
    NotificationChannel mChannel = new NotificationChannel(id, name, importance);
    mChannel.setDescription(description);
    mChannel.enableLights(true);
    mChannel.setLightColor(Color.GREEN);
    mChannel.enableVibration(true);
    mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
    return mChannel;
}
 
開發者ID:jinxul,項目名稱:Baboon,代碼行數:12,代碼來源:MainActivity.java

示例15: openChannel

import android.app.NotificationChannel; //導入方法依賴的package包/類
/**
 * Opens a notification channel and disables the LED and vibration
 */
private void openChannel() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, this.getResources().getString(R.string.notification_channel_library_scanner), android.app.NotificationManager.IMPORTANCE_LOW);
        // Disable lights & vibration
        channel.enableVibration(false);
        channel.enableLights(false);
        channel.setVibrationPattern(null);

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


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