2015-11-25 8 views
5

私はアプリケーションを作成しています。私はParseからデータを取得しており、そのデータを通知に転送して生成してユーザーに表示します。Androidの通知がマシュマロの色アイコンを表示していません

が、何らかの理由で私は正しい色のアイコンを表示することができませんマシュマロ

他のすべてのAndroidのバージョンではその作業を完全に罰金、しかし、私が選択したマシュマロでその不気味な白いアイコンは、実際のではありません。

私の通知コードです。

Intent cIntent = new Intent(context, MainActivity.class); 
     PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, 
       cIntent, PendingIntent.FLAG_UPDATE_CURRENT); 

     NotificationCompat.Builder builder = new NotificationCompat.Builder(context) 
       .setSmallIcon(R.drawable.ic_launcher) 
       .setContentText(data) 
       .setContentTitle("Notification from Parse") 
       .setContentIntent(pendingIntent); 

     Notification notification = builder.build(); 
     NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
     nm.notify(100, notification); 

この問題を解決する方法を教えてください。

答えて

19

最初に:それはマシュマロからではなく、通知アイコンがLollipopからWHITEを開始しました。

チェックアウトhttp://developer.android.com/design/style/iconography.html白いスタイルは、Android Lollipopでの通知の表示方法です。これにソリューションは、通知ビルダーへLargeIconを設定している

Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); 

NotificationCompat.Builder builder = new NotificationCompat.Builder(context) 
       .setSmallIcon(R.drawable.ic_launcher) 
       .setLargeIcon(largeIcon) 
       .setContentText(data) 
       .setContentTitle("Notification from Parse") 
       .setContentIntent(pendingIntent); 
https://developer.android.com/about/versions/android-5.0-changes.html

セカンド - Androidのロリポップで

は、Googleはまた、あなたが(白)通知アイコンの後ろに表示されます色を使用することを示唆しています

setLargeIcon

そして、あなたの通知は次のようになります

.setColor()を使用して通知アイコンの背景色を設定することもできます。

+0

あなたは素晴らしいです。 –

+0

右下に小さなアイコンがありますので、それを削除するにはどうにかしてください。 –

+2

いいえ、あなたの電話機がロックされ、通知が表示されたときに実際にそのアイコンがあなたの通知に表示されます。 –

関連する問題