谷歌地方自动完成视图自动关闭

时间:2018-03-27 14:46:10

标签: android google-maps-api-3

我的谷歌地图api有问题。我在我的项目中使用了Api Key,并且还链接了发行版SHA1 Key。它在调试apk中正常工作,但在发布apk中autocompleteview自动关闭。我检查了Logcat,在logcat中,api密钥与我在android清单文件中的元数据中使用的密钥不同。

   private void manualLocation() {
    try {
        Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN).build((Activity) context);
        startActivityForResult(intent, 1);

    } catch (GooglePlayServicesRepairableException e) {
        // TODO: Handle the error.
    } catch (GooglePlayServicesNotAvailableException e) {
        // TODO: Handle the error.
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 1) {
        if (resultCode == RESULT_OK) {
            Place place = PlaceAutocomplete.getPlace(this, data);
            Log.e("Tag", "Place: " + place.getAddress() + place.getPhoneNumber());
            Log.e("Tag", "Place: " + place.getLatLng() + place.getPlaceTypes());

            if (signup.matches("1")) {
                latitude = String.valueOf(place.getLatLng().latitude);
                longitude = String.valueOf(place.getLatLng().longitude);

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status status = PlaceAutocomplete.getStatus(this, data);
            // TODO: Handle the error.
            Log.e("Tag", status.getStatusMessage());
            locationStatus = "0";
            AppPreferences.savePreferences(Location.this, "locationStatus", locationStatus);

        } else if (resultCode == RESULT_CANCELED) {
            locationStatus = "0";
            AppPreferences.savePreferences(Location.this, "locationStatus", locationStatus);
            // The user canceled the operation.
        }
    }
}
}

我在元数据中使用了密钥" AIzaSyBH9saN7RRHev1QNKWqtIjejojvqJuCswU"但在Logcat中,关键是不同的。我告诉你Logcat。任何人都可以帮助我吗?

BasicNetwork.performRequest: Unexpected response code 403 for https://www.googleapis.com/placesandroid/v1/autocompleteWidget?key=AIzaSyBb2MNLJEmWt-FLJqN28D_-WuxQiMwzUhU

这是Logcat响应

0 个答案:

没有答案