如何创建许可通知渠道。
根据Android文档,我正在处理一项需要从日历中读取数据的任务,我补充说,
<uses-permission android:name="android.permission.READ_CALENDAR" />
但是现在,当我使用一种方法时,
ActivityCompat.checkSelfPermission(this,
Manifest.permission.READ_CALENDAR)
它始终返回-1,并且在调查后始终拒绝许可,我发现我必须在运行时请求许可,并且在我的框架中需要批准多次许可,
我发现允许范围内
。 “ NULL”请参阅日志,以获取更多详细信息,
我尝试使用以下方法添加通知频道
private void createNotificationChannelIfNeeded(int id, String title, String message) {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = title;
String description = message;
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(title, name, importance);
channel.setDescription(description);
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
NotificationManager mNotifyMgr =
(NotificationManager) getApplicationContext().getSystemService(NOTIFICATION_SERVICE);
mNotifyMgr.createNotificationChannel(channel);
}
,但仍会遇到相同的错误。
I am working on one task where I need to read the data from calendar, as per android documentation, I added
<uses-permission android:name="android.permission.READ_CALENDAR" />
but now when I am using a method
ActivityCompat.checkSelfPermission(this,
Manifest.permission.READ_CALENDAR)
it is always returning -1, and permission is denial always, After investigation, I found that I have to request permission at run time, and there are multiple permission required to be granted in my framework,
I found that PermissionEverywhere.getpermission, can solve this issue,
but I am getting error "Developer warning for package Failed to post notification on channel "null" see log for more details
I tried adding the notification channel using below method
private void createNotificationChannelIfNeeded(int id, String title, String message) {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = title;
String description = message;
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(title, name, importance);
channel.setDescription(description);
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
NotificationManager mNotifyMgr =
(NotificationManager) getApplicationContext().getSystemService(NOTIFICATION_SERVICE);
mNotifyMgr.createNotificationChannel(channel);
}
but still getting the same error. please let me know, how to create channel for Permission everywhere class
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论