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


Java NotificationManager.IMPORTANCE_DEFAULT属性代码示例

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


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

示例1: onCreate

@Override
public void onCreate() {
    super.onCreate();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID,
                getString(R.string.apply_on_boot), NotificationManager.IMPORTANCE_DEFAULT);
        notificationChannel.setSound(null, null);
        notificationManager.createNotificationChannel(notificationChannel);

        Notification.Builder builder = new Notification.Builder(
                this, CHANNEL_ID);
        builder.setContentTitle(getString(R.string.apply_on_boot))
                .setSmallIcon(R.mipmap.ic_launcher);
        startForeground(NotificationId.APPLY_ON_BOOT, builder.build());
    }
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:19,代码来源:ApplyOnBootService.java

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

示例3: showNotification

private void showNotification() {
    mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
        NotificationChannel channel = new NotificationChannel(CHANNEL_ID, getString(R.string.aequorea_offline_cache), NotificationManager.IMPORTANCE_DEFAULT);
        mNotificationManager.createNotificationChannel(channel);
    }
    
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID).setSmallIcon(R.mipmap.ic_notification)
        .setContentTitle(getString(R.string.app_name))
        .setContentText(getString(R.string.caching_offline_article));
    
    if (mNotificationManager != null) {
        mNotificationManager.notify(1, builder.build());
    }
}
 
开发者ID:nichbar,项目名称:Aequorea,代码行数:16,代码来源:CacheService.java

示例4: Notify

public Notify(Context context, int ID) {
    this.NOTIFICATION_ID = ID;
    mContext = context;
    // 获取系统服务来初始化对象
    nm = (NotificationManager) mContext
            .getSystemService(NOTIFICATION_SERVICE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        cBuilder = new NotificationCompat.Builder(mContext, mChannelId = mContext.getPackageName().concat(AGENTWEB_VERSION));
        NotificationChannel mNotificationChannel = new NotificationChannel(mChannelId, AgentWebUtils.getApplicationName(context), NotificationManager.IMPORTANCE_DEFAULT);
        NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(NOTIFICATION_SERVICE);
        mNotificationManager.createNotificationChannel(mNotificationChannel);
    } else {
        cBuilder = new NotificationCompat.Builder(mContext);
    }
}
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:16,代码来源:Notify.java

示例5: createNotificationChannels

public static void createNotificationChannels(Context context) {

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

            NotificationChannel diaryChannel = new NotificationChannel(
                    NOTIFICATION_CHANNEL_ID_DIARY,
                    context.getString(R.string.diary_reminder_notification_channel_name),
                    NotificationManager.IMPORTANCE_HIGH);
            diaryChannel.setDescription(context.getString(R.string.diary_reminder_notification_channel_description));

            NotificationChannel playerChannel = new NotificationChannel(
                    NOTIFICATION_CHANNEL_ID_PLAYER,
                    context.getString(R.string.player_notification_channel_name),
                    NotificationManager.IMPORTANCE_DEFAULT);
            playerChannel.setDescription(context.getString(R.string.player_notification_channel_description));

            // Create channels
            NotificationManager notificationManager =
                    (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            notificationManager.createNotificationChannel(diaryChannel);
            notificationManager.createNotificationChannel(playerChannel);
        }

    }
 
开发者ID:jgevans,项目名称:TherapyGuide,代码行数:24,代码来源:NotificationHandler.java

示例6: NotificationHelper

/**
 * 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,代码行数:20,代码来源:NotificationHelper.java

示例7: createDefaultChannel

static void createDefaultChannel(Context context, OreoConfig oreoConfig) {
    if (Build.VERSION.SDK_INT >= 26) {
        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationChannel channel = new NotificationChannel(OreoConfig.DEFAULT_CHANNEL_ID, oreoConfig.getDefaultChannelName(), NotificationManager.IMPORTANCE_DEFAULT);
        channel.setDescription(oreoConfig.getDefaultChannelDescription());
        notificationManager.createNotificationChannel(channel);
    }
}
 
开发者ID:emartech,项目名称:android-mobile-engage-sdk,代码行数:8,代码来源:MessagingServiceUtils.java

示例8: getGroupChatMessageChannel

@RequiresApi(api = Build.VERSION_CODES.O)
public static NotificationChannel getGroupChatMessageChannel(Context context){
    String channelName = context.getString(R.string.group_message_channel);
    NotificationChannel channel = new NotificationChannel(GROUP_CHAT_MESSAGE_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_DEFAULT);
    channel.setSound(NotificationHelper.findNotificationSound(), ATTRIBUTES);
    channel.enableLights(true);
    channel.enableVibration(true);
    return channel;
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:9,代码来源:AppNotificationChannels.java

示例9: getKeyExchangeChannel

@RequiresApi(api = Build.VERSION_CODES.O)
public static NotificationChannel getKeyExchangeChannel(Context context){
    String channelName = context.getString(R.string.key_exchange_channel);
    NotificationChannel channel = new NotificationChannel(KEY_EXCHANGE_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_DEFAULT);
    channel.enableLights(false);
    channel.enableVibration(false);
    return channel;
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:8,代码来源:AppNotificationChannels.java

示例10: createChannel

@NonNull
private static String createChannel(Service context) {
    // Create a channel.
    NotificationManager notificationManager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    CharSequence channelName = "Playback channel";
    int importance = NotificationManager.IMPORTANCE_DEFAULT;
    NotificationChannel notificationChannel =
            new NotificationChannel(CHANNEL_ID, channelName, importance);
    notificationManager.createNotificationChannel(notificationChannel);
    return CHANNEL_ID;
}
 
开发者ID:r3bl-alliance,项目名称:stay-awake-app,代码行数:12,代码来源:HandleNotifications.java

示例11: createChannels

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,代码行数:32,代码来源:NotificationHelper.java

示例12: setupNotificationChannel

@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,代码行数:9,代码来源:OfflineDownloadService.java

示例13: createChannel

@RequiresApi(api = Build.VERSION_CODES.O)
public static void createChannel(@NonNull Context context) {
    Precondition.checkNotNull(context);

    final NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME,
            NotificationManager.IMPORTANCE_DEFAULT);
    channel.setLockscreenVisibility(NotificationCompat.VISIBILITY_PUBLIC);

    final NotificationManager manager = getManager(context);
    manager.deleteNotificationChannel(CHANNEL_ID);
    manager.createNotificationChannel(channel);
}
 
开发者ID:huazhouwang,项目名称:Synapse,代码行数:12,代码来源:ChannelCreator.java

示例14: LocationResultHelper

LocationResultHelper(Context context, List<Location> locations) {
    mContext = context;
    mLocations = locations;

    NotificationChannel channel = new NotificationChannel(PRIMARY_CHANNEL,
            context.getString(R.string.default_channel), NotificationManager.IMPORTANCE_DEFAULT);
    channel.setLightColor(Color.GREEN);
    channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
    getNotificationManager().createNotificationChannel(channel);
}
 
开发者ID:googlecodelabs,项目名称:background-location-updates-android-o,代码行数:10,代码来源:LocationResultHelper.java

示例15: registerChannel

/**
 * Registers the app's notification channel to the system.
 * @param ctx Used to access system
 */
@RequiresApi(Build.VERSION_CODES.O)
private static void registerChannel(Context ctx) {
    NotificationManager mNotifManager =
            (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);

    NotificationChannel mChannel = new NotificationChannel(NOTIFICATION_CHANNEL,
            ctx.getString(R.string.notif_channel_name), NotificationManager.IMPORTANCE_DEFAULT);

    mChannel.setDescription(ctx.getString(R.string.notif_channel_desc));
    mChannel.setLightColor(Color.GREEN);
    mChannel.enableVibration(true);

    mNotifManager.createNotificationChannel(mChannel);
}
 
开发者ID:kfaryarok,项目名称:kfaryarok-android,代码行数:18,代码来源:AlertHelper.java


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