我有一个简单的脚本,在游戏中创建一个www请求,以检查这个apk运行的国家。它在android 9操作系统设备之前工作得很好,但在android 9操作系统设备上失败了。我的www.error给出了一个未知的错误字符串。
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class GeoData : MonoBehaviour
{
private void Start()
{
StartCoroutine(GetText());
}
IEnumerator GetText()
{
UnityWebRequest www = UnityWebRequest.Get("http://ip-api.com/json");// I also changed www string but all in vein
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
//above Android 8 os devices, its comes here and debug "Unknow error"
Debug.Log("Done with Error: " + www.error);
}
else
{
Debug.Log("Final data is ="+ www.text);
string stringToSplit = www.text;
char[] splitters = { ',', ':', '"' };
string[] splittedString = stringToSplit.Split(splitters, System.StringSplitOptions.RemoveEmptyEntries);
foreach (var item in splittedString)
{
Debug.Log(item); // Country is at 6th index
}
}
}
}发布于 2019-06-26 19:32:08
好了,我已经知道问题出在哪里了。一个不安全的URL,现在它在Android 9 Pie中被禁止了。你不能要求。因此URL必须确保如下所示(https)
https://stackoverflow.com/questions/56771050
复制相似问题