2017-11-01 11 views
0

通知アイコン(見出しなし)のみを表示したい。 私はそれが下のコードで行うことができると思ったが、私はこのコードを実行すると、contentTitlecontentTextのHeadsUpも受け取った。私はそれをユーザーに見せたくありません。通知バーのアイコンをタスクバーに表示するにはどうすればいいですか?

私はcustomHeadsUpContentViewを否定しましたが、まだ表示されます。言い換えれば

String id = "my_channel_01"; 
CharSequence name = "someName"; 
String description = "even bigger name"; 
int importance = 0; 
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { 
    importance = android.app.NotificationManager.IMPORTANCE_MIN; 
} 
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { 
    NotificationChannel mChannel = new NotificationChannel(id, name, importance); 
    mChannel.setDescription(description); 
    notificationManager.createNotificationChannel(mChannel); 
} 

NotificationCompat.Builder mBuilder = 
     new NotificationCompat.Builder(application); 
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { 
    mBuilder = new NotificationCompat.Builder(application, id); 
} 
Intent resultIntent = new Intent(application, MainActivity.class); 
PendingIntent resultPendingIntent = 
     PendingIntent.getActivity(application, 
       0, resultIntent, 
       PendingIntent.FLAG_UPDATE_CURRENT 
     ); 

mBuilder.setSmallIcon(R.drawable.big_anchor) 
     .setContentTitle("Status") 
     .setContentText("ARMED") 
     .setOngoing(true) 
     .setCustomHeadsUpContentView(null) // ? 
     .setContentIntent(resultPendingIntent); 

notificationManager.notify(32345, mBuilder.build()); 

--UPDATE--

、私は私の通知は、このなしで表示されるようにしたい: enter image description here --UPDATE--

面白いです何か、このヘッズアップは、API 26(Oreo)を搭載したデバイスでのみ表示されています。ヌーガットと私の携帯電話はすべて動作します。

+0

あなたはタイトルと内容のテキストは、それを削除し、なぜこの行.setContentTitle(「ステータス」) .setContentText(「ARMED」)し、テスト –

+0

を削除するに有用であるとすることができ、試してみてください – Munir

+0

まだ表示されます。明らかに薄い。 –

答えて

0

これを試してみてください、

mBuilder.setSmallIcon(R.drawable.big_anchor) 
    .setOngoing(true) 
    .setCustomHeadsUpContentView(null) 
    .setContentIntent(resultPendingIntent); 
+0

https://imgur.com/a/5mRjcがまだ表示されています。私はこれを取り除きたい。明らかに何か明白です(人々はそれを表示する方法に疑問を呈する傾向がありますが、**表示しない方法**)。 –

関連する問題