服务通知为白色

uqzxnwby  于 2021-07-12  发布在  Java
关注(0)|答案(0)|浏览(208)

我正在开发一个android应用程序,我正在用两部手机测试它,一部是huawei p20 pro,另一部是oneplus 6t。它们都运行相同的android版本(q-29)。
当通知显示在华威它的工作伟大,它的五颜六色,它不是白色的。然而,当它在oneplus 6t上显示时,它是白色和丑陋的。
我读到,这是因为手机的版本,但他们都运行相同的版本,我无法找出它。
我也在清单上加了这一行:

<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
    android:resource="@drawable/applogo" />

这是通知代码:

RemoteViews notificationLayout = new RemoteViews(getPackageName(), R.layout.customnotification);
            notificationLayout.setTextViewText(R.id.customnotificationtext,getString(R.string.runninginbackground));

            NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID);
            Notification notification = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
                    .setContentTitle(getString(R.string.title))
                    .setContentText(getString(R.string.runninginbackground))
                    .addAction(action)
                    .addAction(action2)
                    .setStyle(new NotificationCompat.DecoratedCustomViewStyle())
                    .setCustomContentView(notificationLayout)
                    .setPriority(NotificationManager.IMPORTANCE_HIGH)
                    .setCategory(Notification.CATEGORY_SERVICE)
                    .setColorized(true)
                    .setColor(getColor(R.color.foreGroundBackgroundColor))
                    .setSmallIcon(R.drawable.applogo)
                    .build();

            startForeground(2, notification);

谢谢您。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题