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


Java NotificationManager.IMPORTANCE_HIGH属性代码示例

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


在下文中一共展示了NotificationManager.IMPORTANCE_HIGH属性的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: createNotificationChannel

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

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

示例4: getNotificationChannelID

private String getNotificationChannelID() {
    final String channelID = "GoalieChannelID";

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationManager mNotificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        CharSequence name = getString(R.string.app_name);
        String description = getString(R.string.channel_description);
        int importance = NotificationManager.IMPORTANCE_HIGH;

        NotificationChannel mChannel = new NotificationChannel(channelID, name, importance);
        mChannel.setDescription(description);
        mChannel.enableLights(true);
        mChannel.enableVibration(true);
        mNotificationManager.createNotificationChannel(mChannel);
    }

    return channelID;
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:20,代码来源:MessagingService.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: createNotificationChannel

private void createNotificationChannel() {
  NotificationManager mNotificationManager =
      (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
  CharSequence name = getString(R.string.imagepipeline_notification_channel_name);

  int importance =
      NotificationManager
          .IMPORTANCE_HIGH; // high importance shows the notification on the user screen.

  NotificationChannel mChannel =
      new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, importance);
  mNotificationManager.createNotificationChannel(mChannel);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:ImagePipelineNotificationFragment.java

示例7: showNotification

private void showNotification() {

        final Intent notificationIntent = new Intent(mContext, EditContactActivity.class);
        String CHANNEL_ID = "lead-management-ch";

        notificationIntent.putExtra(
                EditContactActivity.INTENT_EXTRA_CONTACT_NUM, number);

        final PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0,
                notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        final NotificationCompat.Builder notification = new NotificationCompat.Builder(mContext)
                .setSmallIcon(R.drawable.ic_call_black_24dp)
                .setContentTitle("Call in Progress")
                .setTicker("Lead Management")
                .setContentIntent(contentIntent)
                .setContentText("Number: " + number)
                .setChannelId(CHANNEL_ID);

        final NotificationManager manager =
                (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
        if (manager != null) {
            manager.cancel(ID);
            // check build version
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                CharSequence name = "Lead-Management-Channel";
                int importance = NotificationManager.IMPORTANCE_HIGH;
                NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, importance);
                manager.createNotificationChannel(mChannel);
            }
            manager.notify(ID, notification.build());
        }
    }
 
开发者ID:jboss-outreach,项目名称:lead-management-android,代码行数:33,代码来源:CallReceiver.java

示例8: createChannel

private void createChannel(String id, String name, String description) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel mChannel = new NotificationChannel(id, name,
                NotificationManager.IMPORTANCE_HIGH);
        mChannel.setDescription(description);
        mChannel.enableLights(true);
        mChannel.setLightColor(Color.RED);
        mChannel.enableVibration(true);
        mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 100});
        notificationManager.createNotificationChannel(mChannel);
    }
}
 
开发者ID:bsautermeister,项目名称:GeoFencer,代码行数:12,代码来源:SimpleNotification.java

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

示例10: remindUserBecauseCharging

public static void remindUserBecauseCharging(Context context) {
    NotificationManager notificationManager = (NotificationManager)
            context.getSystemService(Context.NOTIFICATION_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel mChannel = new NotificationChannel(
                WATER_REMINDER_NOTIFICATION_CHANNEL_ID,
                context.getString(R.string.main_notification_channel_name),
                NotificationManager.IMPORTANCE_HIGH);
        notificationManager.createNotificationChannel(mChannel);
        }
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context,WATER_REMINDER_NOTIFICATION_CHANNEL_ID)
            .setColor(ContextCompat.getColor(context, R.color.colorPrimary))
            .setSmallIcon(R.drawable.ic_drink_notification)
            .setLargeIcon(largeIcon(context))
            .setContentTitle(context.getString(R.string.charging_reminder_notification_title))
            .setContentText(context.getString(R.string.charging_reminder_notification_body))
            .setStyle(new NotificationCompat.BigTextStyle().bigText(
                    context.getString(R.string.charging_reminder_notification_body)))
            .setDefaults(Notification.DEFAULT_VIBRATE)
            .setContentIntent(contentIntent(context))
            // COMPLETED (17) Add the two new actions using the addAction method and your helper methods
            .addAction(drinkWaterAction(context))
            .addAction(ignoreReminderAction(context))
            .setAutoCancel(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
        notificationBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
    }
    notificationManager.notify(WATER_REMINDER_NOTIFICATION_ID, notificationBuilder.build());
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:31,代码来源:NotificationUtils.java

示例11: remindUserBecauseCharging

public static void remindUserBecauseCharging(Context context) {
    NotificationManager notificationManager = (NotificationManager)
            context.getSystemService(Context.NOTIFICATION_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel mChannel = new NotificationChannel(
                WATER_REMINDER_NOTIFICATION_CHANNEL_ID,
                context.getString(R.string.main_notification_channel_name),
                NotificationManager.IMPORTANCE_HIGH);
        notificationManager.createNotificationChannel(mChannel);
        }
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context,WATER_REMINDER_NOTIFICATION_CHANNEL_ID)
            .setColor(ContextCompat.getColor(context, R.color.colorPrimary))
            .setSmallIcon(R.drawable.ic_drink_notification)
            .setLargeIcon(largeIcon(context))
            .setContentTitle(context.getString(R.string.charging_reminder_notification_title))
            .setContentText(context.getString(R.string.charging_reminder_notification_body))
            .setStyle(new NotificationCompat.BigTextStyle().bigText(
                    context.getString(R.string.charging_reminder_notification_body)))
            .setDefaults(Notification.DEFAULT_VIBRATE)
            .setContentIntent(contentIntent(context))
            .addAction(drinkWaterAction(context))
            .addAction(ignoreReminderAction(context))
            .setAutoCancel(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
        notificationBuilder.setPriority(NotificationCompat.PRIORITY_HIGH);
    }
    notificationManager.notify(WATER_REMINDER_NOTIFICATION_ID, notificationBuilder.build());
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:30,代码来源:NotificationUtils.java

示例12: createChannel

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

示例13: onCreate

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

    sInstance = this;

    Fabric.with(this, new Crashlytics());

    StringsManager.initialize();

    TwitterConfig config = new TwitterConfig.Builder(this)
            .logger(new DefaultLogger(Log.DEBUG))
            .twitterAuthConfig(new TwitterAuthConfig(Constants.TWITTER_CONSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET))
            .debug(true)
            .build();
    Twitter.initialize(config);

    //Create Notification channel in Android O
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        if (notificationManager != null) {
            NotificationChannel mChannel = new NotificationChannel("referendum",
                    StringsManager.getString("notification_channel_name"), NotificationManager.IMPORTANCE_HIGH);
            mChannel.setDescription(StringsManager.getString("notification_channel_description"));
            mChannel.enableLights(true);
            mChannel.setLightColor(Color.RED);
            notificationManager.createNotificationChannel(mChannel);
        }
    }
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:30,代码来源:UOctubreApplication.java

示例14: createNotificationChannel

private void createNotificationChannel() {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
        NotificationChannel genChannel = new NotificationChannel(GENERAL_CHANNEL,
                getResources().getString(R.string.general_channel),
                NotificationManager.IMPORTANCE_HIGH);

        genChannel.setShowBadge(true);
        genChannel.setLightColor(Color.BLUE);
        notificationManager.createNotificationChannel(genChannel);
    }
}
 
开发者ID:emmanuelkehinde,项目名称:TwittaSave-Android,代码行数:11,代码来源:AutoListenService.java

示例15: onCreate

/**
* Called on service creation, sends a notification
*/
  @Override
  public void onCreate() {

      sInstance = this;

      mApp = (HavenApp)getApplication();

      manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
      mPrefs = new PreferenceManager(this);

      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
          mChannel = new NotificationChannel(channelId, channelName,
                  NotificationManager.IMPORTANCE_HIGH);
          mChannel.setDescription(channelDescription);
          mChannel.setLightColor(Color.RED);
          mChannel.setImportance(NotificationManager.IMPORTANCE_MIN);
          manager.createNotificationChannel(mChannel);
      }

      startSensors();

      showNotification();

      PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
      wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
              "MyWakelockTag");
      wakeLock.acquire();
  }
 
开发者ID:guardianproject,项目名称:haven,代码行数:31,代码来源:MonitorService.java


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