API 方向 API 需要密钥 Android

Is API Key Required for Direction Apis Android

我使用下面的代码通过 google api 获取到特定纬度和经度的方向。但是我没有使用 api 键。我正在制作的这个应用程序很快就会被推送到 playstore。我只是想确定我在这里所做的是正确的,还是会给我带来任何问题?

提前致谢:)

if (pc.getLatitude() != null && pc.getLongitude() != null) {

      double latitude = Double.parseDouble(pc.getLatitude());
      double longitude = Double.parseDouble(pc.getLongitude());

      String uri = String.format(Locale.ENGLISH, "http://maps.google.com/maps?daddr=%f,%f (%s)", latitude, longitude, "Location");
      Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                    intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
      if (intent.resolveActivity(mContext.getPackageManager()) != null) {
           Toast.makeText(mContext, R.string.toast_opening_google_maps, Toast.LENGTH_SHORT).show();
           mContext.startActivity(intent);
      } else {
             Toast.makeText(mContext, R.string.toast_no_google_maps_warning, Toast.LENGTH_SHORT).show();
        }
} else {
     Toast.makeText(mContext, R.string.toast_no_ll_warning, Toast.LENGTH_LONG).show();
  }

这是我的 api 用法的又一示例

 String distanceUrl = "http://maps.googleapis.com/maps/api/distancematrix/json?" +
                "origins=" + mOriginLatLng.latitude + "," + mOriginLatLng.longitude +
                "&destinations=" + destination.latitude + "," + destination.longitude +
                "&mode=driving&language=en-EN&sensor=false";

根据 the documentation,您不需要 API 键即可使用 Intent 启动 Google 地图。

根据the documentation,你需要一个API键来使用距离矩阵API。