I am trying to secure WebView
from cleartext traffic. As mentioned in the documentation. I have to set android:usesCleartextTraffic
as false
to achieve this. But this works on API level 23 and above. My minimum sdk is 22. How can I make sure app doesn't crash or create any problem on device running below API level 23 ? Or how can I programmatically set that attribute value in the application
tag in Manifest.xml
?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
As suggested in an article @ Android Developers Blogspot:
You don’t have to set
minSdkVersion
ortargetSdkVersion
of your app to 23 (Android Marshmallow) to useandroid:usesCleartextTraffic
. On older platforms, this attribute is simply ignored and thus has no effect.
Hope this solves your query.