0

通知を作成すると、notifバーにバージョン4.4以降の通知しかない他の携帯電話のアプリアイコンに通知バッジは表示されません。私はちょうど下のスクリーンショットのようなアンドロイドバージョンのすべての種類のアプリのアイコンに沿って赤い通知バッジを表示したいアプリのアイコンに赤いバッジを表示

enter image description here

ここでは基本的に、私は通知を表示するために使用していたコードですユーザは通知バーで通知を受け取りますが、アプリに沿った赤いバッジ番号は受け取りません。

private void sendNotification(NotificationVM source) { 
    Intent intent = new Intent(this, NotificationActivity.class); 
    intent.putExtra(IntentPutNameConstant.NotificationActivity.NOTIFICATION_ID, source.getNotificationId()); 
    intent.putExtra(IntentPutNameConstant.NotificationActivity.NOTIFICATION_TYPE, source.getNotificationType()); 
    intent.putExtra(IntentPutNameConstant.NotificationActivity.USER_FROM_USERNAME, source.getUserFrom().getUsername()); 
    intent.putExtra(IntentPutNameConstant.NotificationActivity.MESSAGE, source.getMessage()); 
    intent.putExtra(IntentPutNameConstant.NotificationActivity.SOURCE_ID, source.getSourceId()); 
    intent.putExtra(IntentPutNameConstant.NotificationActivity.EXTERNAL_URL, source.getExternalUrl()); 

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 


    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, 
      PendingIntent.FLAG_ONE_SHOT); 

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) 
      .setSmallIcon(R.drawable.ic_app_launcher_72) 
      .setContentTitle("Investagrams") 
      .setContentText(source.getMessage()) 
      .setAutoCancel(true) 
      .setSound(defaultSoundUri) 
      .setContentIntent(pendingIntent); 

    //Vibration 
    notificationBuilder.setVibrate(new long[] { 0, 200, 200, 200, 200, 200 }); 


    //LED 
    //notificationBuilder.setLights(Color.RED, 3000, 3000); 

    NotificationManager notificationManager = 
      (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 

    Notification notif = notificationBuilder.build(); 
    notif.flags |= Notification.FLAG_AUTO_CANCEL; 

    /*notif.ledARGB = 0xFFff0000; 
    notif.flags = Notification.FLAG_SHOW_LIGHTS; 
    notif.ledOnMS = 100; 
    notif.ledOffMS = 100;*/ 

    notificationManager.notify((int)source.getNotificationId() /* ID of notification */, notif); 

} 
+1

これはランチャーの仕事であり、アプリの通知とは関係ありません。たとえば、Nova Launcherは通知数を表示できますが、通知数表示メカニズムを持つユーザーに依存します。 – EvilTak

答えて

0

これはデバイスメーカー固有のものです。この機能を備えているデバイスが自動的にこれを行います。その時点で表示されている通知の総数が計算され、その数が表示されます。

関連する問題