1

我正在尝试使用Settings API. 在位置对话框中显示消息Use WiFi and cellular networks for location。选择Yes它时启用位置,但不启用GPS.

这就是我得到的

Google Maps但是当我在同一台设备 上玩时,它会显示Use GPS, WiFi and cellular networks for location如下截图所示的消息。

这也是启用的GPS。我怎样才能达到与Google Maps.

在这里发帖之前,我希望我已经检查了所有可能的选项。在下面找到我的试用列表。

我已将priorityasHIGH_ACCURACY和 min 间隔设置为 5 秒

locationRequest = LocationRequest.create();

// Set the priority of the request
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

// Set the update interval to 10 seconds
locationRequest.setInterval(1000 * 10);

// Set the fastest update interval to 5 seconds
locationRequest.setFastestInterval(1000 * 5);

仅使用FINE_LOCATION权限

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

还提到了一些链接,但没有给出确切的解决方案。我只需要HIGH_ACCURACY默认启用该位置,这会启用GPS任何帮助吗?

4

1 回答 1

1

I had this problem, but after clicking the YES button to permit use GPS, the activity stops and runs the method onPause and then the activity begins in the method onResume. So my solution was start again the localizacion in onResume method

@Override onResume public void () {

         //your code
         LocationRequest = LocationRequest.create ();

         // Set the priority of the request
         locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

         // Set the update interval to 10 seconds
         locationRequest.setInterval (1000 * 10);

         // Set the fastest update interval to 5 seconds
         locationRequest.setFastestInterval (1000 * 5);
         .....
         //start again the localizacion 
         LocationServices.FusedLocationApi.requestLocationUpdates(apiClient, locRequest, this);
于 2016-10-30T00:11:46.467 回答