不再需要手动检查 Google Play 服务版本?

No need to manually check Google Play Services version anymore?

我使用 Google Play 服务已经有一段时间了,现在我正在实现一项需要位置跟踪的功能。在遵循使用 GoogleApiClient 的过时示例后,我在 Android 开发者博客上找到了关于新位置 API 的 post:

https://android-developers.googleblog.com/2017/06/reduce-friction-with-new-location-apis.html

FusedLocationProviderClient client =
    LocationServices.getFusedLocationProviderClient(this);

client.requestLocationUpdates(LocationRequest.create(), pendingIntent)
    .addOnCompleteListener(new OnCompleteListener() {
      @Override
      public void onComplete(@NonNull Task task) {
        Log.d("MainActivity", "Result: " + task.getResult());
      }
    });
}

引起我注意的是 post 底部写的东西,上面写着:

The new API will automatically resolve certain connection failures for you, so you don't need to write code that for things like prompting the user to update Google Play services.

因为我已经使用 GoogleApiAvailabilty 编写了那段代码,所以我很好奇将其删除并让 FusedLocationProviderClient 处理它是否安全?

我试图找到另一个来源来验证这一点但失败了,我对博客底部的半行不满意post,因此post在这里提出问题。

好的,我会在快速测试后回答我自己的问题。我暂时删除了确保 Google Play 服务可用且版本正确的检查。然后在没有 Google Play 服务的模拟器上安装该应用程序,当我尝试使用 LocationServices API 时,我收到一条粘性提示通知:

[app name] won't run unless you update Google Play Services.

所以我想取消支票是安全的。

值得注意的是,除非用户实际与通知交互,否则似乎不会调用侦听器 (Success/Failure/Complete),例如,如果他们只是在您的应用程序中按下其他内容 UI,没有调用听众。