'How to create notification channel for PermissionEverywhere.getpermission
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
