android notification 图标大小,Android notification small icon

东郭昌胤
2023-12-01

I am making an Geo Fencing App with notifications in Android Studio. But I have the problem that the notifications are not showing up.It says that it has no small icon but I did include that in my code.

Error: 02-19 15:06:42.276 1260-1260/? E/NotificationService: Not

posting notification without small icon: Notification(channel=null

pri=2 contentView=null vibrate=[0] sound=null defaults=0x0 flags=0x91

color=0x00000000 vis=PRIVATE) 02-19 15:06:42.276 1260-1260/?

E/NotificationService: WARNING: In a future release this will crash

the app: com.koo.lightmanager 02-19 15:06:42.277 1260-1260/?

E/NotificationService: Error creating vibration waveform with pattern:

[0]

Code:

private void sendNotification(String title, String content) {

Notification.Builder builder = new Notification.Builder(this)

.setSmallIcon(R.mipmap.ic_launcher_round)

.setContentTitle(title)

.setContentText(content);

NotificationManager manager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);

Intent intent = new Intent(this,MapsActivity.class);

PendingIntent contentIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_IMMUTABLE);

builder.setContentIntent(contentIntent);

Notification notification = builder.build();

notification.flags |= Notification.FLAG_AUTO_CANCEL;

notification.defaults |= Notification.DEFAULT_SOUND;

manager.notify(new Random().nextInt(),notification);

}

 类似资料: