Tün*_*nde 5 notifications android android-notifications android-6.0-marshmallow
我正在Android上实现本地通知,我遇到的问题是它们没有出现在Android 6.0(三星S7)上.我正在寻找解决方案,但我找不到任何解决这个问题的方法.我在正确的res/drawable文件夹中有图标,我也定义了通知标题,文本,铃声(原始文件夹)但它没有显示...有我的代码:
Context acontext = getApplicationContext();
PackageManager pm = acontext.getPackageManager();
Intent notificationIntent = pm.getLaunchIntentForPackage(acontext.getPackageName());
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(acontext, 0, notificationIntent, 0);
int notification_icon = acontext.getResources().getIdentifier("icon", "drawable", acontext.getPackageName());
int notificationID = 0;
// Build notification
Notification noti = new Notification.Builder(acontext)
.setContentTitle("Title")
.setContentText("Incoming text")
.setSmallIcon(notification_icon)
.setContentIntent(pendingIntent)
.setLights(Color.RED, 1, 1)
.build();
NotificationManager notificationManager = (NotificationManager) acontext.getSystemService(Context.NOTIFICATION_SERVICE);
// hide the notification after its selected
noti.sound = Uri.parse("android.resource://" + acontext.getPackageName() + "/raw/incoming");
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(notificationID, noti);
Run Code Online (Sandbox Code Playgroud)
有没有其他人遇到过这个问题?任何帮助,将不胜感激.谢谢.
小智 0
必须启用 Google Play 服务才能在 Android 设备上接收推送通知。如果 Google Play 服务已启用并且一般故障排除步骤未能解决问题,则可能需要重置应用程序。要重置应用程序,请转至设置 \xe2\x86\x92 应用程序 \xe2\x86\x92 PagerDuty 并点击清除数据。
\n\n对于 Android 6.0 及更高版本,请确保将应用程序设置为优先模式下的优先应用程序。
\n\n对于 Android 6.0 及更高版本,请检查应用程序是否因 Doze 模式而静音。
\n| 归档时间: |
|
| 查看次数: |
10815 次 |
| 最近记录: |