我收到来自 sonarqube 的警告
Implement permissions on this exported component.
同时,Android 文档明确指出任何带有 <intent-filters>
的 Activity 应标记为 exported="true"
.
https://developer.android.com/guide/topics/manifest/activity-element#exported
block 引用>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.这是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>
那么,对于这个问题有什么建议吗?谢谢
最佳答案
如果您不想为组件实现任何权限,只需声明空字符串即可 - android:permission=""
关于Android 使用 Intent 过滤器导出规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73399278/