0

我在我的应用程序中创建了抬头通知。因为我也在通知中使用了我的应用程序图标。但这并没有显示出来。而不是得到方形图标。搜索有关该问题,发现上面的棒棒糖发生这种情况。还找到了为上述棒棒糖创建图标的方法。将我的应用程序图标(png)转换为 svg 格式。这对我来说很好。我可以在我的应用通知中获得图标。但我真的很困惑,我所做的是否是正确的格式?如果不是最好的方法是什么。请任何机构给我一个适当的解释。

我知道设置小图标和大图标。我已将通知小图标设置为 svg 格式。这完美地显示在我的通知中......我想知道的是,在通知小图标中设置 svg 格式图标是正确的方法吗?

4

2 回答 2

0

此代码适用于所有 android 版本:

//    builder.setContentText(msg)
            //        .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            //        .setVibrate(new long[]{500, 500})
            //        .setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
                    .setSmallIcon(android.R.drawable.ic_menu_upload)
           //          .setOnlyAlertOnce(true)
           //          .setOngoing(false)
           //          .setPriority(NotificationCompat.PRIORITY_DEFAULT);
于 2020-06-16T08:09:43.053 回答
0

如果你想制作大图标,试试这个。

 Bitmap icon2 = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);

 NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle();
 bigText.bigText(textBody);

 notificationBuilder.setLargeIcon(icon2)
                    .setSmallIcon(R.mipmap.ic_launcher)
                    .setContentTitle(pushTitle)
                    .setContentText(contentText)
                    .setStyle(bigText)
                    .setLights(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary), 3000, 3000)
                    .setVibrate(new long[]{500, 500, 500, 500})
                    .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                    .setAutoCancel(true)
                    .setPriority(NotificationCompat.PRIORITY_MAX)
                    .setContentIntent(pendingIntent);
于 2020-06-16T08:16:31.033 回答