Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.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
Android:Google Place API queryAutoComplete在API 17-API 19上提供零结果_Android_Google Places Api_Nativescript - Fatal编程技术网

Android:Google Place API queryAutoComplete在API 17-API 19上提供零结果

Android:Google Place API queryAutoComplete在API 17-API 19上提供零结果,android,google-places-api,nativescript,Android,Google Places Api,Nativescript,以下请求在web和android API 17+中运行良好: 搜索字符串:Bruņinieku ie 搜索url: 搜索结果: { "predictions" : [ { "description" : "Bruņinieku iela, Rīga, Latvija", "id" : "6904e5bf90ff4e34b179aba2e28643efc9007017", "matched_substrings" : [

以下请求在web和android API 17+中运行良好:

搜索字符串:
Bruņinieku ie

搜索url:

搜索结果:

{
   "predictions" : [
      {
         "description" : "Bruņinieku iela, Rīga, Latvija",
         "id" : "6904e5bf90ff4e34b179aba2e28643efc9007017",
         "matched_substrings" : [
            {
               "length" : 13,
               "offset" : 0
            }
         ],
    ...
现在,如果我在末尾添加另一个字母,那么请求在web和android API 21+中仍然可以正常工作,但在API 17-API 19中则不行:

搜索字符串:
Bruņinieku iel

搜索url:

搜索结果(Web和API 21+):

搜索结果(API 17-API 19):


为什么?!毫无意义!起初,我认为可能是位置、半径或语言,所以删除了这些-仍然是相同的问题。这不应该发生,但它确实发生了。

好极了,浪费了半天。事实证明,旧的API不会自动将未知符号(如
ņ
)转换为utf-8。您必须自己使用
encodeURIComponent(搜索字符串)
来完成此操作,它会生成url:

{
   "predictions" : [
      {
         "description" : "Bruņinieku iela, Rīga, Latvija",
         "id" : "6904e5bf90ff4e34b179aba2e28643efc9007017",
         "matched_substrings" : [
            {
               "length" : 15,
               "offset" : 0
            }
         ],
    ...
{
    "predictions": [],
    "status": "ZERO_RESULTS"
}