当前位置: 首页>>代码示例>>Java>>正文


Java NotificationChannel.enableLights方法代码示例

本文整理汇总了Java中android.app.NotificationChannel.enableLights方法的典型用法代码示例。如果您正苦于以下问题:Java NotificationChannel.enableLights方法的具体用法?Java NotificationChannel.enableLights怎么用?Java NotificationChannel.enableLights使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.NotificationChannel的用法示例。


在下文中一共展示了NotificationChannel.enableLights方法的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: 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

示例3: createNotificationChannel

import android.app.NotificationChannel; //导入方法依赖的package包/类
@TargetApi(26)
private void createNotificationChannel() {

    notificationChannelClass = new NotificationChannel("class", "Class Notifications", NotificationManager.IMPORTANCE_LOW);
    notificationChannelClass.setDescription("Notifications about classes.");
    notificationChannelClass.enableLights(false);
    notificationChannelClass.enableVibration(false);
    notificationChannelClass.setBypassDnd(false);
    notificationChannelClass.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
    notificationChannelClass.setShowBadge(false);

    notificationManager.createNotificationChannel(notificationChannelClass);

    notificationChannelReminder = new NotificationChannel("reminder", "Reminders", NotificationManager.IMPORTANCE_MAX);
    notificationChannelReminder.setDescription("Notifications about events.");
    notificationChannelReminder.enableLights(true);
    notificationChannelReminder.setLightColor(sharedPreferences.getInt("primary_color", ContextCompat.getColor(this, R.color.teal)));
    notificationChannelReminder.enableVibration(true);
    notificationChannelReminder.setBypassDnd(true);
    notificationChannelReminder.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
    notificationChannelReminder.setShowBadge(true);

    notificationManager.createNotificationChannel(notificationChannelReminder);

}
 
开发者ID:arminghofrani,项目名称:chalkboard,代码行数:26,代码来源:Background.java

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

示例5: 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:fendoudebb,项目名称:PlayAndroid,代码行数:25,代码来源:MediaNotificationManager.java

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

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

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

示例10: createNotificationChannel

import android.app.NotificationChannel; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.O)
public void createNotificationChannel() {
    NotificationManager notificationManager = getSystemService(NotificationManager.class);
    if (notificationManager != null) {
        NotificationChannel channel = new NotificationChannel(
                Constants.NOTIFICATION_CHANNEL_ID_RS,
                getString(R.string.notification_channel_running_status),
                NotificationManager.IMPORTANCE_DEFAULT
        );
        channel.setShowBadge(false);
        channel.enableLights(false);
        channel.enableVibration(false);
        channel.setSound(null, null);

        notificationManager.createNotificationChannel(channel);
    }
}
 
开发者ID:fython,项目名称:Blackbulb,代码行数:18,代码来源:BlackbulbApplication.java

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

示例12: addNotificationAttributes

import android.app.NotificationChannel; //导入方法依赖的package包/类
@RequiresApi(api = 26)
private static NotificationChannel addNotificationAttributes(final NotificationChannel notificationChannel) {
    final int notificationColor = ContextCompat.getColor(BaseApplication.get(), R.color.colorPrimary);
    final Uri notificationSound = Uri.parse("android.resource://" + BaseApplication.get().getPackageName() + "/" + R.raw.notification);

    notificationChannel.enableLights(true);
    notificationChannel.setLightColor(notificationColor);
    notificationChannel.enableVibration(true);
    notificationChannel.setSound(notificationSound,
            new AudioAttributes.Builder()
                    .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
                    .setFlags(AudioAttributes.USAGE_NOTIFICATION)
                    .build()
    );

    return notificationChannel;
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:18,代码来源:ToshiNotificationBuilder.java

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

示例14: createNotificationChannel

import android.app.NotificationChannel; //导入方法依赖的package包/类
public void createNotificationChannel() {
        NotificationManager mNotificationManager =
                (NotificationManager) myContext.getSystemService(Context.NOTIFICATION_SERVICE);
// The id of the channel.
// The user-visible name of the channel.
        CharSequence name = myContext.getString(R.string.channel_name);
// The user-visible description of the channel.
        int importance = NotificationManager.IMPORTANCE_DEFAULT;
        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);
        mNotificationManager.createNotificationChannel(mChannel);
    }
 
开发者ID:doerfli,项目名称:leavemealone,代码行数:18,代码来源:OreoNotificationHelper.java

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


注:本文中的android.app.NotificationChannel.enableLights方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。