棉花糖(API-23)下方如何使用android:usesCleartextTraffic [英] How to use android:usesCleartextTraffic below Marshmallow (API-23)

查看:1362
本文介绍了棉花糖(API-23)下方如何使用android:usesCleartextTraffic的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从明文通信中保护WebView.如文档中所述.我必须将android:usesCleartextTraffic设置为false才能实现此目的.但这适用于API级别23及更高级别.我的最低sdk是22.如何确保应用程序不会崩溃或在低于API级别23的设备上运行时造成任何问题?或者如何在Manifest.xmlapplication标记中以编程方式设置该属性值?

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:

您无需将应用程序的minSdkVersiontargetSdkVersion设置为23(Android棉花糖)即可使用android:usesCleartextTraffic. 在较旧的平台上,该属性将被忽略,因此无效.

You don’t have to set minSdkVersion or targetSdkVersion of your app to 23 (Android Marshmallow) to use android:usesCleartextTraffic. On older platforms, this attribute is simply ignored and thus has no effect.

希望这可以解决您的查询.

Hope this solves your query.

这篇关于棉花糖(API-23)下方如何使用android:usesCleartextTraffic的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆