Custom permission can improve the security of your app. By setting permission, you can protect your app from unauthorized access to apps. For example, we will register Activity/service/reciever in the Androidmanifest.xml, filter the action we want to receive in Intent-filter, If there is a send source that is not what we know sends us a matching action, it has the potential to affect our app and may even compromise the user.
How to use
- Register permission
- Adding permissions in the corresponding Activity/service and reciever
- Using permission
a simple example
Create two project, one Sendbroadcastrecieverdemon, one Recievedemon
- Register a custom permission in the Recievedemon project Androidmanifest.xml
- Create a reciever and add permission permissions
- Using permission in Sendbroadcastrecieverdemon projects
- Send intent to the Recievedemon project in the Sendbroadcastrecieverdemon project
- OK, so you can receive the intent message sent by Sendbroadcastrecieverdemon in the Recievedemon project.
It's not easy, haha.
Android Custom permission simple and practical manual