Vij
Vij

Reputation: 445

android unable pick location from place picker

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());
     } }

Upvotes: 4

Views: 2104

Answers (4)

Waleed Abdalmajeed
Waleed Abdalmajeed

Reputation: 824

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.

Upvotes: 2

Dhara Patel
Dhara Patel

Reputation: 359

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

Upvotes: 0

DilbertDave
DilbertDave

Reputation: 3446

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.

Upvotes: 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.

Upvotes: -1

Related Questions