棉花糖(API-23)下方如何使用android:usesCleartextTraffic [英] How to use android:usesCleartextTraffic below Marshmallow (API-23)
问题描述
我正在尝试从明文通信中保护WebView
.如文档中所述.我必须将android:usesCleartextTraffic
设置为false
才能实现此目的.但这适用于API级别23及更高级别.我的最低sdk是22.如何确保应用程序不会崩溃或在低于API级别23的设备上运行时造成任何问题?或者如何在Manifest.xml
的application
标记中以编程方式设置该属性值?
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
?
推荐答案
如文章 @ Android开发者博客:
As suggested in an article @ Android Developers Blogspot:
您无需将应用程序的
minSdkVersion
或targetSdkVersion
设置为23(Android棉花糖)即可使用android:usesCleartextTraffic
. 在较旧的平台上,该属性将被忽略,因此无效.
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.
这篇关于棉花糖(API-23)下方如何使用android:usesCleartextTraffic的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!