当前位置: 首页>>代码示例>>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;未经允许,请勿转载。