我正在尝试显示android应用程序的通知。通知在通知区域中显示得很完美,但是即使在将优先级设置为"max“之后,提提通知也不会出现。下面是我的通知生成器代码
Intent intent = new Intent(this, MainActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
Log.e("notification arrived","");
long[] pattern = {500,500,500,500,500};
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Notification.Builder n = new Notification.Builder(this)
.setContentTitle("Best Deals")
.setContentText(body)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pIntent)
.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(Notification.PRIORITY_MAX)
.setSound(alarmSound)
.setVibrate(pattern);
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
manager.notify(0, n.build());发布于 2017-06-23 07:07:47
我已经测试了您的代码,一切都如我所期望的那样工作。

也许你必须改变你的测试环境?
我使用了API 25的Nexus 7仿真器。这些在我的build.gradle里
buildToolsVersion "25.0.2"
minSdkVersion 21
targetSdkVersion 23注意:某些设备/制造商给您提供了禁用(或默认情况下已禁用)提示通知的选项。
https://stackoverflow.com/questions/44714926
复制相似问题