Issue
Firstly: I was looking for an answer but didn't found it here neither in Google.
When I run this code (in kotlin and on Android 10):
startActivityForResult(Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS),Uri.parse("package:" + packageName)), 55)
It ends with exception:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS dat=package:dantem.im }
But this code works without any problems:
startActivityForResult(Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS, Uri.parse("package:" + packageName)), 200)
This code works too, but it show list of all packages which I don't want:
startActivity(Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS))
Where is problem?
Solution
The documentation for ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS
says that it takes no input. That is why you will find that many, if not all, Android devices give you the ActivityNotFoundException
— your Uri
on the Intent
causes that Intent
to not match any <intent-filter>
.
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.