Exploring Android 12: Permission Group Lookup
We are going to talk about a simple feature introduces in Android 12: Permission Group Lookup. With this, developers can determine:
- which permission group a permission belongs to; or
- which permissions belong to a certain permission group.
In this article, we will create a simple application that demonstrates these 2 new methods. The end result can be seen in the image below:
Where’s the Source Code?
android-12-samples/permission-group-lookup at master · hanmajid/android-12-samples
Sample projects for Android 12. Contribute to hanmajid/android-12-samples development by creating an account on GitHub.
Step by Step Explanation
Follow the steps provided below to create this application.
1. Open Android Studio. Create new project with “Empty Activity” option.
2. First, we need to update our layout,
activity_main.xml file. Here’s what it would look like:
Copy-paste the code snippet below to create that layout:
3. Lastly, update the
MainActivity.kt file. Go ahead and copy-paste the code snippet below. The most important things to notice here is the usage of
getPlatformPermissionsForGroup methods. Take extra note on how the method callback was executed inside the
Executor‘s thread (not in the main UI thread).
4. That’s it! Run your app and it should look like this:
As always, thanks for reading!
Want to learn more about Android 12?
Check out all of our articles from “Exploring Android 12” series here: