Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.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定位API-onLocationChaged不';我没接到电话_Android - Fatal编程技术网

新的android定位API-onLocationChaged不';我没接到电话

新的android定位API-onLocationChaged不';我没接到电话,android,Android,我在使用谷歌新位置API时遇到问题 我正在编写一个应用程序,根据用户的位置列出附近的位置。 90%的情况下,我的应用程序运行良好,但有时我的LocationListener无法获得回调,因此我怀疑设备无法找到位置。 我只添加了粗略的位置权限,所以API只使用网络查找位置 我不想发布完整的源代码,但基本方法是: 在onCreate()方法中,我初始化LocationClient字段 在onStart中,我调用locationClient.connect(在onStop disconnect()

我在使用谷歌新位置API时遇到问题

我正在编写一个应用程序,根据用户的位置列出附近的位置。 90%的情况下,我的应用程序运行良好,但有时我的LocationListener无法获得回调,因此我怀疑设备无法找到位置。 我只添加了粗略的位置权限,所以API只使用网络查找位置

我不想发布完整的源代码,但基本方法是:

  • 在onCreate()方法中,我初始化LocationClient字段
  • 在onStart中,我调用locationClient.connect(在onStop disconnect()中)
  • 在onConnected回调中,我检查LocationClient.getLastLocation是否为null,如果为null,则使用它,否则调用requestLocations
我的方法似乎有效,但在某些设备中,onLocationChaged从未被调用,我不知道为什么。 不幸的是,我没有任何设备产生这种故障,所以我不能提供任何关于fenomenon的日志,我只是希望有人遇到同样的问题。 任何帮助都将不胜感激