添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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 ?

So will this crash or create any problem on devices running lower then API 23 ? @NileshRathod sagar suri Feb 1, 2018 at 4:26 may be or may be not because I'm not sure about this because no more details in Android docs about it AskNilesh Feb 1, 2018 at 4:28

As suggested in an article @ Android Developers Blogspot:

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.

When you use usesCleartextTraffic in manifest, you get the following warning :

Attribute usesCleartextTraffic is only used in API level 23 and higher (current min is 19).

The default value of usesCleartextTraffic is as the following :

  • for apps that target API level 27 or lower is "true".
  • for apps that target API level 28 or higher default to "false".
  • This attribute was added in API level 23.

    This flag is ignored on Android 7.0 (API level 24) and above if an Android Network Security Config is present.

    https://developer.android.com/guide/topics/manifest/application-element https://android-developers.googleblog.com/2016/04/protecting-against-unintentional.html

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question . Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers .