【发布时间】:2021-03-23 14:25:28
【问题描述】:
我确实认真地尝试了每一种方法和每一个 sn-p,但我仍然无法在中国品牌设备上显示提示通知。
所以昨天我想为什么不再试一次,但毕竟我仍然无法显示提示通知,直到我手动将应用程序转到设置并授予应用程序的浮动权限。
现在你们中的大多数人可能会说为什么不将用户导航到设置,当他/她第一次打开应用程序时,但没有人喜欢即使有其他应用程序(我不是在谈论像 WhatsApp 这样的白名单应用程序)有 10K 的下载量可以显示抬头通知
这是我的代码,顺便说一句,我尝试设置声音、振动和灯光,但仍然没有显示抬头,是的,我在每次构建后都会卸载我的应用
public void showNotification(View v){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
NotificationChannel nc = new NotificationChannel("n","pop up notification", NotificationManager.IMPORTANCE_HIGH);
nc.enableLights(true);
nc.setLightColor(Color.BLUE);
nc.enableVibration(true);
nc.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
NotificationManager nm = getSystemService(NotificationManager.class);
nm.createNotificationChannel(nc);
}
Notification.Builder notification = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
notification = new Notification.Builder(this,"n")
.setContentTitle("Pop up notification")
.setSmallIcon(R.drawable.ic_launcher_background);
}else{
notification = new Notification.Builder(this)
.setContentTitle("Pop up notification")
// .setPriority(Notification.PRIORITY_MAX)
.setSmallIcon(R.drawable.ic_launcher_background);
}
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1,notification.build());
}
【问题讨论】:
标签: java android notifications redmi-device