为什么熔融LocationProviderClientClient.getLastLocation永远不会调用OnSuccessListener?

时间:2018-10-03 16:37:05

标签: android android-location fusedlocationproviderapi android-fusedlocation android-googleapiclient

在奇巧上,当我这样做

fusedLocationProviderClient.getLastLocation()
  .addOnSuccessListener(new OnSuccessListener<Location>() {
      @Override
      public void onSuccess(Location location) {
          if (location == null) { 
            Log.w(TAG, "Their is no last grabbed location currently available"); 
            return;
          }
          Log.v(TAG, "Processing last grabbed location");
      }
  })
  .addOnFailureListener(new OnFailureListener() {
      @Override
      public void onFailure(@NonNull Exception e) {
          Log.w(TAG, "Error trying to get last grabbed location");
      }
  });   

然后永远不会调用OnSuccessListener和OnFailureListener!它在lollipop +上工作,但在我的kitkat上,它从来没有执行过任何监听程序...知道为什么吗?

1 个答案:

答案 0 :(得分:0)

好吧,我发现这是因为Google Play服务未更新为最新版本