10

図のように...
通知アイコン(赤色の左側)が表示されます。
しかし、黒い矢印通知ドロワーの通知アイコンとしてアプリアイコンを設定する方法

enter image description here

public void notify(View view){ 
    notification.setSmallIcon(R.drawable.ic_stat_name); 
    notification.setTicker("Welcome to ****"); 
    notification.setWhen(System.currentTimeMillis()); 
    notification.setContentTitle("abcd"); 
    notification.setContentText("abcd"); 


    Intent intent = new Intent(this, home.class); 
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); 
    notification.setContentIntent(pendingIntent); 


    NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
    nm.notify(uniqueID, notification.build()); 
} 
+2

あなたは何をしようとしたのですか? –

+0

あなたの通知ビルダーの使用.setSmallIcon(R.drawable.ic_launcher) – Sathish

+0

で、私は私のコード –

答えて

30

によって示されるように、私は私たちがそれを解決できるように、あなたのコードを投稿することが推奨されるアプリのアイコンを表示する必要があります。どのような方法は、あなたの通知ビルダーでこのコードを試してください:大きいアイコンを設定

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) 
       .setSmallIcon(R.mipmap.ic_launcher) 
       .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), 
         R.mipmap.ic_launcher)) 
       .setContentTitle(title) 
       .setContentText(message) 
       .setAutoCancel(true) 
       .setSound(defaultSoundUri) 
       .setContentIntent(pendingIntent); 

     android.app.NotificationManager notificationManager = 
       (android.app.NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 

     notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); 

は、あなたがそれ以上の情報

+0

私のコードを投稿しました –

+0

いいえ、この行を追加してください:.setLargeIcon(BitmapFactory.decodeResource(context.getResources()、 R.mipmap.ic_launcher)) – Manikanta

+0

うまくいきました! !おかげ –

10

を持っている場合は、以下のtrick.Commentは、私がここに答えるためにその少し遅れて知っているし、またそのすでに回答されてしかし、私はここでfirebaseの通知を使用して簡単に修正を探しに来ました。私はここに訪れるような人は、単にマニフェストにメタデータを追加され、firebase通知の推奨と簡単な方法で解決を行うことができます。

Reference

<!-- Set custom default icon. This is used when no icon is set for incoming notification messages. --> 
<meta-data 
    android:name="com.google.firebase.messaging.default_notification_icon" 
    android:resource="@drawable/ic_stat_ic_notification" /> 
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming notification message. --> 
<meta-data 
    android:name="com.google.firebase.messaging.default_notification_color" 
    android:resource="@color/colorAccent" /> 
+1

あなたの答えが最も有用でした。ありがとう。 –

関連する問題