Home > Software design >  Android exported rules with intent-filters
Android exported rules with intent-filters

Time:08-18

I got warning from sonarqube that says

Implement permissions on this exported component.

sonarqube warning


Meanwhile the android documentation clearly state that any activity with <intent-filters> should be marked as exported="true".

https://developer.android.com/guide/topics/manifest/activity-element#exported

If an activity in your app includes intent filters, set this element to "true" to allow other apps to start it.

For example, if the activity is the main activity of the app and includes the category "android.intent.category.LAUNCHER".

If this element is set to "false" and an app tries to start the activity, the system throws an ActivityNotFoundException.

This is some piece of code from the warning in AndroidManifest.xml

<activity
    android:name=".example.WebViewActivity"
    android:exported="true"
    android:launchMode="singleTop">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        
        <data android:host="example.com" />
        <data android:scheme="http" />
        <data android:scheme="https" />
        <data android:pathPrefix="/app/Webview" />
    </intent-filter>
</activity>

So, is there any suggestions for this issue ? thank you

CodePudding user response:

Hope this discussion can help you

https://community.sonarsource.com/t/false-positive-rule-xml-implement-permissions-on-this-exported-component-for-the-main-android-activity/38993/2

  • Related