Search code examples
androidintentfilterdeep-linking

Android: Is it a good practice to define custom permission for an activity which has intent filters?


I have an app in which an activity is supposed to be started by deep links in messages. Should I define custom permission for that activity so that malicious service/apps cannot call it? I am not sure if this is a good practice. Any help would be appreciated.

Thanks in advance.


Solution

  • Should I define custom permission for that activity so that malicious service/apps cannot call it?

    Probably not. If the activity will only ever be started by your code, get rid of the <intent-filter>. If, on the other hand, the activity is supposed to be started by something else, that "something else" will not request your custom permission, and so it is guaranteed to fail to start the activity.