4

I am unable to pick the location from place picker.

It disables the select button when select place but when to search location and pick then it enable select button.

I am using play services version

 com.google.android.gms:play-services-location:9.4.0 

and com.google.android.gms:play-services:9.4.0

 btn_locationSend.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
                try {
                    startActivityForResult(builder.build(ChatThreadActivity.this),PLACE_PICKER_REQUEST);
                } catch (GooglePlayServicesRepairableException e) {
                    e.printStackTrace();
                } catch (GooglePlayServicesNotAvailableException e) {
                    e.printStackTrace();
                }
            }
        });
    }





    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_OK) {
        switch (requestCode) {
            case PLACE_PICKER_REQUEST:
                Place place = PlacePicker.getPlace(this,data);
                LatLng location = place.getLatLng();
                String toastMsg = String.format("Place: %s", place.getName());
     } }
Adnan
  • 2,931
  • 3
  • 23
  • 35
Vij
  • 445
  • 2
  • 9

4 Answers4

2

If your problem is not solved yet. Enable Google Places API for Android in dev console.

It's because you didn't give permission to use Places on google maps. Just go to the link and enable Google Places API for Android.

  • _Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline._ – Bugs Feb 01 '17 at 10:18
  • You saved my time bro ! Thanks a lot – Ghorbanzadeh May 29 '17 at 06:59
  • @Ghorbanzadeh glad it help :) – Waleed Abdalmajeed May 29 '17 at 07:14
1

It maybe a bit late but check out my answer to what sounds like the same problem (Disable select button while selecting location of anonymous location using Place picker google API in android)

Basically make sure that the API Key in your AndroidManifest.xml has the correct name. While com.google.android.maps.v2.API_KEY will work for the Maps API the Places API requires com.google.android.geo.API_KEY.

If you are using the Maps API then you can use the same key and both APIs will work using the latter kay name.

DilbertDave
  • 3,406
  • 3
  • 33
  • 42
  • please check your google API which enable places in Google Places API for Android -> place API . you can check this https://console.developers.google.com – Vij Dec 20 '16 at 06:10
0

use this

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

insted of this

com.google.android.maps.v2.API_KEY
Dhara Patel
  • 359
  • 5
  • 19
-1

The code looks fine. In fact, I tried re-running it and found no such observation; the SELECT button of the Use this location pop-up dialog was always enabled. However, when I manually disabled my Internet connection, the SELECT button became disabled. So, I believe, if your Internet connection is intermittent or has a problem, you might be able to observe the same thing.

  • ok thanx faheeem but there was no internet problem that you told, when i select location from place picker select buttton disables but when i manually search place it enables to select. – Vij Aug 15 '16 at 05:41
  • this issue has nothing to do with the internet connection. refer to http://stackoverflow.com/questions/39092825/disable-select-button-while-selecting-location-of-anonymous-location-using-place/39507069#39507069 – Siddharth Sep 16 '16 at 09:05