【问题标题】:Android Pie - No response for JSONObjectRequest in VolleyAndroid Pie - Volley 中的 JSONObjectRequest 没有响应
【发布时间】:2019-06-03 05:52:56
【问题描述】:

我无法在 Volley for Android Pie 中获取任何响应? Android Pie 需要什么特殊配置吗?

【问题讨论】:

  • 欢迎来到 SO,请阅读 how to ask 并编辑您的问题,详细说明您所做的事情、您希望实现的目标以及遇到的错误

标签: android api android-volley


【解决方案1】:

我在这里使用下面的代码

第一步在android项目的res文件夹中创建xml文件夹

步骤 2 在 xml 文件夹中创建一个文件,如下所示:

#

文件名:network_security_config.xml

    <network-security-config>
     <base-config cleartextTrafficPermitted="true">
       <trust-anchors>
        <certificates src="system" />
      </trust-anchors>
     </base-config>
  </network-security-config>
#

AndroidManifest.xml 中的第 3 步

< application
android:name=".ExampleApplication"
android:networkSecurityConfig="@xml/network_security_config"
android:allowBackup="false"
tools:replace="android:allowBackup"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

【讨论】:

    【解决方案2】:

    添加

    android:usesCleartextTraffic="true"
    

    到您的清单 &lt;application 标记。

    并确保您已获得 Internet 权限。

    【讨论】:

    • 非常感谢。问题已解决。我可以知道它是什么意思以及为什么需要它吗?
    • 这只是android P中引入的一个额外的保护布局,可以防止一些不安全的连接。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多