當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。