Android 将地点添加到 Google 地点数据库不起作用

Android Add Place to Google Places database doesn't work

我正在使用 Google 地图和 Google 地点开发 android 应用程序。 当用户在地图上长按时,我会向他展示一个表单,他可以在其中添加有关他所点击地点的详细信息,然后我想将其作为新的 Google 地点添加到 Google 数据库中. 这是他提交表格之前和之后我所做的:

在onCreate()中:

mGoogleApiClient = new GoogleApiClient
                .Builder(this)
                .addApi(Places.GEO_DATA_API)
                .enableAutoManage(this, 0, this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();

提交表格后:

private void addPlaceToGoogleDbAndToTrip()
{
    final Double lat = getIntent().getExtras().getDouble("lat");
    final Double lng = getIntent().getExtras().getDouble("lng");
    final String placeName = newPlaceNameET.getText().toString();
    final String address = newPlaceAddressET.getText().toString();
    final String website = newPlaceWebsiteET.getText().toString();
    final String phoneNumber = newPlacePhoneET.getText().toString();
    LatLng latlng = new LatLng(lat, lng);

AddPlaceRequest place =
        new AddPlaceRequest(
                placeName, // Name
                latlng, // Latitude and longitude
                address, // Address
                Collections.singletonList(Place.TYPE_POINT_OF_INTEREST), // Place types
                phoneNumber, // Phone number
                Uri.parse("www.SomeWebsite.co.il") // Website
        );

Places.GeoDataApi.addPlace(mGoogleApiClient, place).setResultCallback(new ResultCallback<PlaceBuffer>()
{
    @Override
    public void onResult(PlaceBuffer places)
    {

        if (!places.getStatus().isSuccess()) {

            Log.e(TAG, "Place query did not complete. Error: " + places.getStatus().toString());
            places.release();
            return;
        }

        final Place place = places.get(0);
        newPlaceID = place.getId();
        Log.i(TAG, "Place add result: " + place.getName());
        places.release();

    }
});
}

但是 places.get(0) 曾经 return 一个空地方,现在我什至不明白......我得到一个返回的结果出错。它说:"ERROR_OPERATION_FAILED, resolution=null".

我的清单也有这个:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
<meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="@string/google_maps_key" />

知道可能是什么问题吗? API 在我的开发人员控制台中启用。

谢谢!

使用 com.google.android.geo.API_KEY 而不是 com.google.android.maps.v2.API_KEY