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


Java NotificationManager.IMPORTANCE_LOW屬性代碼示例

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


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

示例1: initNotificationManager

private void initNotificationManager() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        final Stopwatch watch = Stopwatch.createStarted();
        final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        final NotificationChannel received = new NotificationChannel(Constants.NOTIFICATION_CHANNEL_ID_RECEIVED,
                getString(R.string.notification_channel_received_name), NotificationManager.IMPORTANCE_DEFAULT);
        received.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.coins_received),
                new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
                        .setLegacyStreamType(AudioManager.STREAM_NOTIFICATION)
                        .setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT).build());
        nm.createNotificationChannel(received);

        final NotificationChannel ongoing = new NotificationChannel(Constants.NOTIFICATION_CHANNEL_ID_ONGOING,
                getString(R.string.notification_channel_ongoing_name), NotificationManager.IMPORTANCE_LOW);
        nm.createNotificationChannel(ongoing);

        final NotificationChannel important = new NotificationChannel(Constants.NOTIFICATION_CHANNEL_ID_IMPORTANT,
                getString(R.string.notification_channel_important_name), NotificationManager.IMPORTANCE_HIGH);
        nm.createNotificationChannel(important);

        log.info("created notification channels, took {}", watch);
    }
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:24,代碼來源:WalletApplication.java

示例2: createNotificationChannelForAndroidO

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,代碼行數:16,代碼來源:NovaNotificationManager.java

示例3: createChannel

@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,代碼行數:24,代碼來源:MediaNotificationManager.java

示例4: createNotificationChannel

@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,代碼行數:25,代碼來源:Background.java

示例5: createMainNotificationChannel

@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,代碼行數:16,代碼來源:NotificationClass.java

示例6: createNotificationChannel

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,代碼行數:16,代碼來源:HomeActivity.java

示例7: createNotificationChannel

private void createNotificationChannel() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        if (notificationManager.getNotificationChannel(NOTIFICATION_CHANNEL_ID) == null) {
            NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID,
                    getString(R.string.debugoverlay_notification_channel_name), NotificationManager.IMPORTANCE_LOW);
            notificationManager.createNotificationChannel(channel);
        }
    }
}
 
開發者ID:Manabu-GT,項目名稱:DebugOverlay-Android,代碼行數:9,代碼來源:DebugOverlayService.java

示例8: setUpChannels

/**
 * Handles setting up a notification channel for the app
 *
 * @param context calling context
 */
public static void setUpChannels(Context context) {
    NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        // If the Android version is Oreo or greater
        // Create a notification channel
        NotificationChannel mChannel = new NotificationChannel(NOTIFICATION_CHANNEL, context.getString(R.string.notification_channel_name), NotificationManager.IMPORTANCE_LOW);
        mNotificationManager.createNotificationChannel(mChannel);
    }
}
 
開發者ID:jthomperoo,項目名稱:Forge,代碼行數:14,代碼來源:Notifications.java

示例9: createNotificationChannel

/**
 * Notification channel setup for devices running Android Oreo or later.
 */
private void createNotificationChannel(Context context) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    NotificationChannel notificationChannel = new NotificationChannel(
      NAVIGATION_NOTIFICATION_CHANNEL, context.getString(R.string.channel_name),
      NotificationManager.IMPORTANCE_LOW);
    notificationManager.createNotificationChannel(notificationChannel);
  }
}
 
開發者ID:mapbox,項目名稱:mapbox-navigation-android,代碼行數:11,代碼來源:MapboxNavigationNotification.java

示例10: getLikesChannel

@RequiresApi(api = Build.VERSION_CODES.O)
public static NotificationChannel getLikesChannel(Context context){
    String channelName = context.getString(R.string.likes_channel);
    NotificationChannel channel = new NotificationChannel(LIKES_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_LOW);
    channel.enableLights(true);
    return channel;
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:7,代碼來源:AppNotificationChannels.java

示例11: getAudioChannel

@RequiresApi(api = Build.VERSION_CODES.O)
public static NotificationChannel getAudioChannel(Context context){
    String channelName = context.getString(R.string.audio_channel);
    NotificationChannel channel = new NotificationChannel(AUDIO_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_LOW);
    channel.enableLights(false);
    channel.enableVibration(false);
    return channel;
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:8,代碼來源:AppNotificationChannels.java

示例12: getNewPostChannel

@RequiresApi(api = Build.VERSION_CODES.O)
public static NotificationChannel getNewPostChannel(Context context){
    String channelName = context.getString(R.string.new_posts_channel);
    NotificationChannel channel = new NotificationChannel(NEW_POST_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_LOW);
    channel.enableLights(true);
    channel.enableVibration(true);
    return channel;
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:8,代碼來源:AppNotificationChannels.java

示例13: getFriendRequestsChannel

@RequiresApi(api = Build.VERSION_CODES.O)
public static NotificationChannel getFriendRequestsChannel(Context context){
    String channelName = context.getString(R.string.friend_requests_channel);
    NotificationChannel channel = new NotificationChannel(FRIEND_REQUESTS_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_LOW);
    channel.enableLights(true);
    channel.enableVibration(true);
    return channel;
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:8,代碼來源:AppNotificationChannels.java

示例14: DefaultNotificationsPresenter

public DefaultNotificationsPresenter( App app )
{
  this.app = app;
  notificationManager =
    (NotificationManager) app.getSystemService( Context.NOTIFICATION_SERVICE );
  String favorite = app.getResources().getString( R.string.favorite );

  // Since API 26 we need to manage notification channels
  if ( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O )
  {
    Resources resources = app.getResources();
    String channelId = resources.getString( R.string.notificationsChannelId );
    String channelName = resources.getString( R.string.notificationsChannelName );
    String channelDescription = resources.getString( R.string.notificationsChannelDescription );

    NotificationChannel quotesChannel = new NotificationChannel(
      channelId, channelName, NotificationManager.IMPORTANCE_LOW
    );
    quotesChannel.setDescription( channelDescription );
    // Channel gets registered by systems and persists until app cache cleared or uninstalled.
    // It is fine to recreate it on each app launch, because it won't change.
    notificationManager.createNotificationChannel( quotesChannel );
    // Use new builder with vector icon
    notificationBuilder = new NotificationCompat.Builder( app, channelId )
      .setSmallIcon( R.drawable.ic_format_quote_white_24dp )
      .addAction( R.drawable.ic_favorite_white_24dp, favorite, createFavoriteActionIntent() );
  }
  else
  {
    // Use deprecated builder with image icon
    notificationBuilder = new NotificationCompat.Builder( app )
      .setSmallIcon( R.drawable.ic_format_quote_white_24dp_png )
      .addAction( R.drawable.ic_favorite_white_24dp_png, favorite, createFavoriteActionIntent() );
  }
  notificationBuilder.setContentIntent( createContentIntent() );
  notificationBuilder.setAutoCancel( true );
}
 
開發者ID:dr0id3v,項目名稱:QuotesOnDesign,代碼行數:37,代碼來源:DefaultNotificationsPresenter.java

示例15: createNotificationChannel

@TargetApi(Build.VERSION_CODES.O)
private void createNotificationChannel() {
    NotificationChannel mChannel = new NotificationChannel(getClass().getSimpleName(), getString(R.string.app_name), NotificationManager.IMPORTANCE_LOW);
    notificationManager.createNotificationChannel(mChannel);
}
 
開發者ID:Omico,項目名稱:CurrentActivity,代碼行數:5,代碼來源:FloatViewService.java


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