有什么方法可以在安装我的应用程序时默认启用所有通知设置?
用户正在接收通知,但默认情况下声音是禁用的,我们需要在设备上手动启用它。并非所有用户都可以手动执行此操作。很高兴知道在安装我们的应用程序时是否有任何方法可以检查所有这些内容,例如 WhatsApp 或 Telegram(它们默认检查所有内容)
最佳答案
尝试在 AndroidManifest 文件中使用以下权限
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
并为 Oreo 及以上版本设置通知优先级 IMPORTANCE_HIGH
Oreo 及以上版本,PRIORITY_HIGH 或 PRIORITY_MAX
Oreo 以下版本
Reference link for priority note
Oreo以下版本优先
mBuilder.setSmallIcon(R.drawable.app_logo)
.setAutoCancel(true)
.setContentIntent(resultPendingIntent)
.setContentTitle(title)
.setStyle(bigPictureStyle)
.setSound(soundUri)
.setPriority(NotificationCompat.PRIORITY_HIGH) // prirority here for version below Oreo
.setWhen(System.currentTimeMillis())
.setLargeIcon(BitmapFactory.decodeResource(mCtx.getResources(), R.drawable.app_logo))
.setContentText(message)
.build();
奥利奥及以上优先
关于android - 在我的 Android 应用程序中默认启用所有通知设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54490143/