TEL:400-8793-956
当前位置:程序、服务器

如何更改NotificationCompat.Builder的图像图标?

提问者: 近期获赞: 浏览人数: 发布时间:2021-01-06 12:56:53

 问:你好

 
请帮我。
 
如何更改NotificationCompat.Builder的图像图标?
 
 
答:请使用以下代码:-
 
 NotificationCompat.Builder notificationBuilder =新的NotificationCompat.Builder(上下文)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setLargeIcon(BitmapFactory.decodeResource(context.getResources(),
                        R.mipmap.ic_launcher))
                .setContentTitle(标题)
                .setContentText(消息)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);
 
        android.app.NotificationManager notificationManager =
                (android.app.NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
 
        notificationManager.notify(0 / *通知ID * /,notificationBuilder.build());
上一篇: 如何为iPhone建议一个随机数生成库
下一篇: 平行阵列