Exploring Android 12: Permission Group Lookup

M Farhan Majid
2 min readMar 29, 2022

--

We are going to talk about a simple feature introduces in Android 12: Permission Group Lookup. With this, developers can determine:

  1. which permission group a permission belongs to; or
  2. which permissions belong to a certain permission group.

To achieve those, we are introduced to 2 new methods: getGroupOfPlatformPermission and getPlatformPermissionsForGroup.

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:

Group Permission Lookup in action. It displays the permission group of ACCESS_FINE_LOCATION permission and the permissions that belong to STORAGE permission group.

Where’s the Source Code?

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:

This is what activity_main.xml should 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 getGroupOfPlatformPermission and getPlatformPermissionsForGroup methods. Take extra note on how the method callback was executed inside theExecutor‘s thread (not in the main UI thread).

4. That’s it! Run your app and it should look like this:

Group Permission Lookup in action. It displays the permission group of ACCESS_FINE_LOCATION permission and the permissions that belong to STORAGE permission group.

As always, thanks for reading!

Want to learn more about Android 12?

Check out all of our articles from “Exploring Android 12” series here:

Exploring Android 12

9 stories

--

--

Responses (1)