java – How to enforce the custom permission on an Activity in Android?-ThrowExceptions

Exception or error:

I have created a custom permission in android as:


How will I enforce this in my Activity in AndroidManifest.xml file?

How to solve:

Use android:permission attribute into activity tag.

Like below

<activity android:permission=""
            android:label="@string/activity_label" />

And you need to add uses-permission to your custom permission, when your other application needs to launch this activity.

<uses-permission android:name=""/>

An In-Depth Introduction to
the Android Permission Model
is a very good article to understand permission in Android. And How to use custom permissions in Android? is also a very good SO thread.

Leave a Reply

Your email address will not be published. Required fields are marked *