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