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