Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
截击无法访问应用程序中的URL,Android 10_Android_Android Studio_Kotlin_Android Volley - Fatal编程技术网

截击无法访问应用程序中的URL,Android 10

截击无法访问应用程序中的URL,Android 10,android,android-studio,kotlin,android-volley,Android,Android Studio,Kotlin,Android Volley,刚刚完成我的应用程序,使用截击从我的数据库中提取数据并将其放入应用程序。我有两部手机要测试,一部可以正常工作,但另一部不行。它甚至没有击中服务器(日志中没有任何内容)。在4G和WiFi上试用(与另一个相同的WiFi网络,工作正常,手机已打开) 我无法解决这个问题。这款手机可以在应用程序中很好地连接到互联网,它使用Google Play游戏和测试广告,我还将链接直接插入手机的Chrome浏览器中,就这样。还尝试了其他URL,比如谷歌,但也失败了。日志上没有错误 这两款应用的唯一区别在于,一款在安卓

刚刚完成我的应用程序,使用截击从我的数据库中提取数据并将其放入应用程序。我有两部手机要测试,一部可以正常工作,但另一部不行。它甚至没有击中服务器(日志中没有任何内容)。在4G和WiFi上试用(与另一个相同的WiFi网络,工作正常,手机已打开)

我无法解决这个问题。这款手机可以在应用程序中很好地连接到互联网,它使用Google Play游戏和测试广告,我还将链接直接插入手机的Chrome浏览器中,就这样。还尝试了其他URL,比如谷歌,但也失败了。日志上没有错误

这两款应用的唯一区别在于,一款在安卓7上(工作正常),另一款在安卓10像素3A上(该应用“没有特殊权限”,在设置中变灰)

代码如下:

var dbURLcheckData = "http://myURLgoesHere.com/App/sql/dbRestoreData.php"
//dbURLcheckData = "http://google.com"
val urlTextField = findViewById<TextView>(com.company.appName.R.id.urlForTestingRestore)
urlTextField.text = dbURLcheckData

val queue = Volley.newRequestQueue(this)
val stringRequest = StringRequest(
    Request.Method.GET, dbURLcheckData,
    Response.Listener<String> { response ->
        Toast.makeText(applicationContext,"response: $response", Toast.LENGTH_SHORT).show()
    },
    Response.ErrorListener {
        Toast.makeText(applicationContext,"error getting backup data\n$dbURLcheckData", Toast.LENGTH_SHORT).show()
        // this is the things that always shows up on one phone, the other phone is successful
    })

queue.add(stringRequest)
var dbURLcheckData=”http://myURLgoesHere.com/App/sql/dbRestoreData.php"
//dbURLcheckData=”http://google.com"
val urlTextField=findviewbyd(com.company.appName.R.id.urlForTestingRestore)
urlTextField.text=dbURLcheckData
val queue=Volley.newRequestQueue(此)
val stringRequest=stringRequest(
Request.Method.GET,dbURLcheckData,
Response.Listener{Response->
Toast.makeText(applicationContext,“response:$response”,Toast.LENGTH\u SHORT.show())
},
Response.ErrorListener{
Toast.makeText(applicationContext,“获取备份数据时出错\n$dbURLcheckData”,Toast.LENGTH\u SHORT.show())
//这些东西总是出现在一部手机上,而另一部手机是成功的
})
添加(stringRequest)

请在AndroidManifest.xml中进行如下更改:

<application
    ....
    android:usesCleartextTraffic="true">


问题在于最新android版本上的http。将上面的行添加到应用程序标记将修复它。

请在AndroidManifest.xml中进行如下更改:

<application
    ....
    android:usesCleartextTraffic="true">


问题在于最新android版本上的http。将上面的行添加到应用程序标记中将解决此问题。

效果很好,太棒了,谢谢!当它允许时,将标记为答案。欢迎!上述解决方法将允许应用程序使用HTTP而不是HTTPS协议。。。现在。但也许不是永远。谷歌正在致力于更安全的计算标准,因此,真正的解决方案是使用HTTPS,而不是HTTP。Works,太棒了,谢谢!当它允许时,将标记为答案。欢迎!上述解决方法将允许应用程序使用HTTP而不是HTTPS协议。。。现在。但也许不是永远。谷歌正在致力于更安全的计算标准,因此,真正的解决方案是使用HTTPS,而不是HTTP。