1

I am integrating place picker but I have already enable places api but it opens and close immediately.

I have created api key and puted it on manifest file still it not working.in my logcat it gives me error

2019-03-08 10:31:41.640 2837-2358/? E/Places: Places API for Android does not seem to be enabled for your app. See https://developers.google.com/places/android/signup for more details. 2019-03-08 10:31:41.651 4713-4713/? E/Places: Place Picker closing due to PLACES_API_ACCESS_NOT_CONFIGURED 2019-03-08 10:31:41.775 2837-2358/? E/Places: Places API for Android does not seem to be enabled for your app. See https://developers.google.com/places/android/signup for more details. 2019-03-08 10:31:41.776 2837-2358/? E/AsyncOperation: serviceID=65, operation=SearchPlaces OperationException[Status{statusCode=PLACES_API_ACCESS_NOT_CONFIGURED, resolution=null}]

here is my code

<meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="key" />


 @SuppressLint("MissingPermission")
    private void showPlacePicker() {
        PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
        try {
            startActivityForResult(builder.build(NewOrderActivity.this), PLACE_PICKER_REQUEST);
        } catch (GooglePlayServicesRepairableException e) {
            e.printStackTrace();
        } catch (GooglePlayServicesNotAvailableException e) {
            e.printStackTrace();
        }
    }

  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == PLACE_PICKER_REQUEST) {

            if (resultCode == RESULT_OK) {
                Place place = PlacePicker.getPlace(data, NewOrderActivity.this);
                edt_pickup_address.setText(place.getAddress());
                Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
                try {
                    List<Address> listAddresses = geocoder.getFromLocation(place.getLatLng().latitude, place.getLatLng().longitude, 1);
                    if (null != listAddresses && listAddresses.size() > 0) {
                      /*  post_area = listAddresses.get(0).getSubLocality();
                        post_city = listAddresses.get(0).getSubAdminArea();
                        post_state = listAddresses.get(0).getAdminArea();*/

                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }


                String place_phone_number = "" + place.getPhoneNumber();
                if (!TextUtils.isEmpty(place_phone_number)) {
                    String[] phone_number = place_phone_number.split(" ");
                    String s = "";
                    for (int i = 0; i < phone_number.length; i++) {
                        if (i != 0) {
                            s = s + phone_number[i];
                        }
                    }
//                    et_contact_no_add_company.setText(s);
                } else {
//                    et_contact_no_add_company.setText("");
                }
                if (place.getWebsiteUri() != null) {
//                    et_website_add_company.setText("" + place.getWebsiteUri());
                } else {
//                    et_website_add_company.setText("");
                }
            }
        }
    }
Vrushi Patel
  • 2,361
  • 1
  • 17
  • 30
Mind Werx
  • 77
  • 12
  • Possible duplicate of [Android Google Places API, getAutocompletePredictions returns status 'PLACES\_API\_ACCESS\_NOT\_CONFIGURED'](https://stackoverflow.com/questions/31449649/android-google-places-api-getautocompletepredictions-returns-status-places-api) – ADM Mar 08 '19 at 05:25
  • but i have done it already still it clos – Mind Werx Mar 08 '19 at 05:29

2 Answers2

0

As per Google new update the Place Picker Deprecate and it will not longer available in future, here is official statement

Deprecation notice: Place Picker

Notice: The Place Picker (Android, iOS) is deprecated as of January 29, 2019. This feature will be turned off on July 29, 2019, and will no longer be available after that date. To continue using the Place Picker with Places SDK for iOS v.2.7.0 through the deprecation period, do NOT disable the Places SDK for iOS. Read the migration guides (Android, iOS) to learn more.

So, the other side u can use the Place Autocomplete

But here is some limitation in new Place API you must enable the Billing account to use the Place Autocomplete.

Reminder: To use the Places API, you must get an API key and you must enable billing. You can enable billing when you get your API key (see the Quick guide) or as a separate process (see Usage and Billing).

Alternative solution: get the latLong from place name using Geocoder

code4rox
  • 941
  • 9
  • 34
0

Deprecation notice: Google Play Services version of the Places SDK for Android

ndroid

Please refer this link

https://developers.google.com/places/android-sdk/autocomplete

Keshav Gera
  • 10,807
  • 1
  • 75
  • 53