当我在andorid 5.0中生成通知时,通知状态图标变为白色

时间:2014-12-18 11:08:00

标签: android android-notifications

当我在android 5(L)

中使用以下代码时,我的通知图标变为白色

这是我的代码:

private void generateSimpleNotification(){

        NotificationCompat.Builder mNotificationBuilder=new NotificationCompat.Builder(this);

        mNotificationBuilder.setSmallIcon(R.drawable.ic_launcher);

        mNotificationBuilder.setContentText("App notification text here");

        mNotificationBuilder.setContentTitle("App notification Title here");

        // Creates an explicit intent for an Activity in your app

        Intent resultIntent=new Intent(this,NotificationActivity.class);

         // The stack builder object will contain an artificial back stack for the
        // started Activity.
        // This ensures that navigating backward from the Activity leads out of
        // your application to the Home screen.

        TaskStackBuilder mStackBuilder=TaskStackBuilder.create(this);
        // Adds the back stack for the Intent (but not the Intent itself)

        mStackBuilder.addParentStack(NotificationParentActivity.class);

        // Adds the Intent that starts the Activity to the top of the stack
        mStackBuilder.addNextIntent(resultIntent);


        PendingIntent mPendingIntent=mStackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);

        mNotificationBuilder.setContentIntent(mPendingIntent);

        NotificationManager mNotificationManager =
                (NotificationManager) getSystemService(
                        Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
        mNotificationManager.notify(0, mNotificationBuilder.build());

    }

我使用setSmallIcon(R.drawable.ic_launcher);

的下方图标

以下是图标大小

drawable-hdpi 72x72

drawable-mdpi 48x48

drawable-xhdpi 96x96

drawable-xhdpi 144x144

现在问题是我的android luncher图标在我的通知状态栏中变为白色以及如何解决它。

下面的

是屏幕截图notification with white icons

1 个答案:

答案 0 :(得分:4)

在搜索了一下后,它看起来像是从andorid 5.0我们只能在透明背景图像上使用白色我只在开发者网站下面阅读

Android notification guide

从上面的网站上面说过

Notification icons should only be a white-on-transparent background image.