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


Java NotificationChannel.setLockscreenVisibility方法代码示例

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


在下文中一共展示了NotificationChannel.setLockscreenVisibility方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

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

示例2: createNotificationChannel

import android.app.NotificationChannel; //导入方法依赖的package包/类
@RequiresApi(Build.VERSION_CODES.O)
private String createNotificationChannel(){
    String channelId = "VBrowserNotification";
    String channelName = "前台下载通知";
    NotificationChannel chan = new NotificationChannel(channelId,
            channelName, NotificationManager.IMPORTANCE_HIGH);
    chan.setLightColor(Color.BLUE);
    chan.setImportance(NotificationManager.IMPORTANCE_NONE);
    chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
    NotificationManager service = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    service.createNotificationChannel(chan);
    return channelId;
}
 
开发者ID:xm0625,项目名称:VBrowser-Android,代码行数:14,代码来源:DownloadForegroundService.java

示例3: NotificationHelper

import android.app.NotificationChannel; //导入方法依赖的package包/类
/**
 * Registers notification channels, which can be used later by individual notifications.
 *
 * @param ctx The application context
 */
public NotificationHelper(Context ctx) {
    super(ctx);

    NotificationChannel chan1 = new NotificationChannel(PRIMARY_CHANNEL,
            getString(R.string.noti_channel_default), NotificationManager.IMPORTANCE_DEFAULT);
    chan1.setLightColor(Color.GREEN);
    chan1.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
    getManager().createNotificationChannel(chan1);

    NotificationChannel chan2 = new NotificationChannel(SECONDARY_CHANNEL,
            getString(R.string.noti_channel_second), NotificationManager.IMPORTANCE_HIGH);
    chan2.setLightColor(Color.BLUE);
    chan2.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
    getManager().createNotificationChannel(chan2);
}
 
开发者ID:googlesamples,项目名称:android-NotificationChannels,代码行数:21,代码来源:NotificationHelper.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包/类
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: createAlarmChannel

import android.app.NotificationChannel; //导入方法依赖的package包/类
private void createAlarmChannel(String uri) {
    Log.e("KCA-A", "recv: " + uri);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        String soundKind = getStringPreferences(getApplicationContext(), PREF_KCA_NOTI_SOUND_KIND);
        boolean isVibrate = soundKind.equals(getString(R.string.sound_kind_value_mixed)) || soundKind.equals(getString(R.string.sound_kind_value_vibrate));
        notificationManager.deleteNotificationChannel(ALARM_CHANNEL_ID);
        while (!alarmChannelList.isEmpty()) {
            notificationManager.deleteNotificationChannel(alarmChannelList.poll());
        }

        AudioAttributes.Builder attrs = new AudioAttributes.Builder();
        attrs.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION);
        attrs.setUsage(AudioAttributes.USAGE_NOTIFICATION);

        String channel_name = createAlarmId(uri, isVibrate);
        alarmChannelList.add(channel_name);
        NotificationChannel channel = new NotificationChannel(alarmChannelList.peek(),
                getStringWithLocale(R.string.notification_appinfo_title), NotificationManager.IMPORTANCE_HIGH);
        channel.setSound(Uri.parse(uri), attrs.build());
        channel.enableVibration(isVibrate);
        channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
        notificationManager.createNotificationChannel(channel);
    }
}
 
开发者ID:antest1,项目名称:kcanotify,代码行数:25,代码来源:KcaAlarmService.java

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

示例8: createChannel

import android.app.NotificationChannel; //导入方法依赖的package包/类
@RequiresApi(Build.VERSION_CODES.O)
private void createChannel() {
    NotificationManager
            mNotificationManager =
            (NotificationManager) this
                    .getSystemService(Context.NOTIFICATION_SERVICE);
    // The user-visible name of the channel.
    CharSequence name = "Servicio en Bus";
    // The user-visible description of the channel.
    String description = "Control del estado 'en bus'";
    int importance = NotificationManager.IMPORTANCE_DEFAULT;
    NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, importance);
    // Configure the notification channel.
    mChannel.setDescription(description);
    mChannel.setShowBadge(false);
    mChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
    mNotificationManager.createNotificationChannel(mChannel);
}
 
开发者ID:InspectorIncognito,项目名称:androidApp,代码行数:19,代码来源:OnBusService.java

示例9: createServiceValidatorChannel

import android.app.NotificationChannel; //导入方法依赖的package包/类
@RequiresApi(Build.VERSION_CODES.O)
private void createServiceValidatorChannel() {
    NotificationManager
            mNotificationManager =
            (NotificationManager) this
                    .getSystemService(Context.NOTIFICATION_SERVICE);
    // The user-visible name of the channel.
    CharSequence name = "Validación de Servico";
    // The user-visible description of the channel.
    String description = "Validación del servicio en que se viajó'";
    int importance = NotificationManager.IMPORTANCE_DEFAULT;
    NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID_VALIDATION, name, importance);
    // Configure the notification channel.
    mChannel.setDescription(description);
    mChannel.setShowBadge(false);
    mChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
    mNotificationManager.createNotificationChannel(mChannel);
}
 
开发者ID:InspectorIncognito,项目名称:androidApp,代码行数:19,代码来源:OnBusService.java

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

示例11: createNotificationChannel

import android.app.NotificationChannel; //导入方法依赖的package包/类
private String createNotificationChannel(
        Context context, MockDatabase.MessagingStyleCommsAppData mockNotificationData) {

    // NotificationChannels are required for Notifications on O (API 26) and above.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

        // The id of the channel.
        String channelId = mockNotificationData.getChannelId();

        // The user-visible name of the channel.
        CharSequence channelName = mockNotificationData.getChannelName();
        // The user-visible description of the channel.
        String channelDescription = mockNotificationData.getChannelDescription();
        int channelImportance = mockNotificationData.getChannelImportance();
        boolean channelEnableVibrate = mockNotificationData.isChannelEnableVibrate();
        int channelLockscreenVisibility =
                mockNotificationData.getChannelLockscreenVisibility();

        // Initializes NotificationChannel.
        NotificationChannel notificationChannel =
                new NotificationChannel(channelId, channelName, channelImportance);
        notificationChannel.setDescription(channelDescription);
        notificationChannel.enableVibration(channelEnableVibrate);
        notificationChannel.setLockscreenVisibility(channelLockscreenVisibility);

        // Adds NotificationChannel to system. Attempting to create an existing notification
        // channel with its original values performs no operation, so it's safe to perform
        // the below sequence.
        NotificationManager notificationManager =
                (NotificationManager)
                        context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.createNotificationChannel(notificationChannel);

        return channelId;
    } else {
        // Returns null for pre-O (26) devices.
        return null;
    }
}
 
开发者ID:googlesamples,项目名称:android-WearAccessibilityApp,代码行数:40,代码来源:NotificationsActivity.java

示例12: createChannels

import android.app.NotificationChannel; //导入方法依赖的package包/类
public void createChannels(){

        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {

            NotificationChannel mChannelOne = new NotificationChannel(CHANNEL_GENERAL_ID, CHANNEL_GENERAL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
            mChannelOne.setDescription(CHANNEL_GENERAL_ABOUT);
            mChannelOne.enableLights(false);
            mChannelOne.setLightColor(getColor(R.color.colorPrimary));
            mChannelOne.setShowBadge(true);
            mChannelOne.enableVibration(false);
            mChannelOne.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
            getNotificationManager().createNotificationChannel(mChannelOne);

            NotificationChannel mChannelTwo = new NotificationChannel(CHANNEL_BUG_TRACKER_ID, CHANNEL_BUG_TRACKER_NAME, NotificationManager.IMPORTANCE_HIGH);
            mChannelTwo.setDescription(CHANNEL_BUG_TRACKER_ABOUT);
            mChannelTwo.enableLights(true);
            mChannelTwo.enableVibration(true);
            mChannelTwo.setLightColor(getColor(R.color.colorPrimary));
            mChannelTwo.setShowBadge(true);
            getNotificationManager().createNotificationChannel(mChannelTwo);

            NotificationChannel mChannelThree = new NotificationChannel(CHANNEL_SERVICE_ID, CHANNEL_SERVICE_NAME, NotificationManager.IMPORTANCE_MIN);
            mChannelThree.setDescription(CHANNEL_SERVICE_ABOUT);
            mChannelThree.enableLights(false);
            mChannelThree.enableVibration(false);
            mChannelThree.setLightColor(getColor(R.color.colorPrimary));
            mChannelThree.setShowBadge(false);
            getNotificationManager().createNotificationChannel(mChannelThree);
        }


    }
 
开发者ID:zeevy,项目名称:grblcontroller,代码行数:33,代码来源:NotificationHelper.java

示例13: setupNotificationChannel

import android.app.NotificationChannel; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.O)
private void setupNotificationChannel() {
  NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  NotificationChannel channel = new NotificationChannel(Constants.NOTIFICATION_CHANNEL,
    "Offline", NotificationManager.IMPORTANCE_DEFAULT);
  channel.setLightColor(Color.GREEN);
  channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
  manager.createNotificationChannel(channel);
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:10,代码来源:OfflineDownloadService.java

示例14: createChannel

import android.app.NotificationChannel; //导入方法依赖的package包/类
/**
 * Create notification channel for Android O
 */
@RequiresApi(Build.VERSION_CODES.O)
private void createChannel() {
    final CharSequence name = getString(R.string.channel_name);
    final int importance = NotificationManager.IMPORTANCE_LOW;
    final NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
    channel.setShowBadge(false);
    channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
    channel.enableVibration(false);
    channel.enableLights(false);
    channel.setBypassDnd(false);
    final NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    nm.createNotificationChannel(channel);
}
 
开发者ID:steevp,项目名称:UpdogFarmer,代码行数:17,代码来源:SteamService.java

示例15: createChannel

import android.app.NotificationChannel; //导入方法依赖的package包/类
@TargetApi(26)
private void createChannel() {
    NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME,
            NotificationManager.IMPORTANCE_HIGH);
    notificationChannel.enableLights(true);
    notificationChannel.enableVibration(true);
    notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
    getManager().createNotificationChannel(notificationChannel);
}
 
开发者ID:wulkanowy,项目名称:wulkanowy,代码行数:10,代码来源:NotificationBuilder.java


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