Protecting components with custom permissions

The Android platform defines a set of default permissions, which are used to secure system services and application components. Largely, these permissions work in the most generic case, but often when sharing bespoke functionality or components between applications it will require a more tailored use of the permissions framework. This is facilitated by defining custom permissions.

This recipe demonstrates how you can define your own custom permissions.

How to do it…

Let's get started!

  1. Before adding any custom permissions, you need to declare string resources for the permission labels. You can do this by editing the strings.xml file in your application project folder under res/values/strings.xml:
    <string ...

Get Android Security Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.