I was looking at some lint errors and notice that there are two ways to transition activities.
From what I learned from various internet sources I have always been assigning each activity in my manifest an intent-filter with an action name and then calling that with an intent to go to that activity.
However this has given me the: “Exported Activity does not require permission” lint error. Some have said this can be a weird issue and that it is better to go to (use the startActivity() method) by referring to the activity class. By calling the Class of the activity instead of an intent filter.
Can anyone attest to which way is better? However it does seem the way that does not prompt a lint error would be the better way…
Thanks!
The recommended approach is that an
Activityshould not have a registered<intent-filter>section in the manifest unless it is meant to be used by external apps. An example of this would be for viewing a particular document mime-type using something like anIntentactionACTION_VIEW. This is is basically an implicitIntentaction.If your
Activityclasses are only meant to be used internally by your own app’s components then they should only be started using expiclitIntentsfor example…In this case, the app component starting the
Activity‘knows’ what it wants to do and starts a specificActivityto do it.