0

I am using the new Google Places SDK: AutocompleteSupportFragment.

whenever i select an address from the result list it doesn't save it and show it on the field.

I am not sure why.

this is my code below: i declaed the variable at the top of the class:

Place shipAddress;

and called this method where i needed:

        final AutocompleteSupportFragment editAddress = (AutocompleteSupportFragment)  getSupportFragmentManager().findFragmentById(R.id.autocomplete_fragment);
        editAddress.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME));

        editAddress.setOnPlaceSelectedListener(new PlaceSelectionListener() {
            @Override
            public void onPlaceSelected(Place place) {
                shipAddress = place;
            }

            @Override
            public void onError(Status status) {
                Log.e("ERROR", status.getStatusMessage());
            }
        });

i am also using the result in another method calling:

address = shipAddress.getAddress().toString();

but finally i get an error that variable address is invoked on a null object.

Shaii
  • 13
  • 1
  • 7

1 Answers1

0

Places SDK has been Depricated You need to migrate to new PLACES API.. You can find solution by below guideline.

https://stackoverflow.com/a/55045772/10579969

Official page https://developers.google.com/places/android-sdk/client-migration#place_picker

Navin Kumar
  • 3,393
  • 3
  • 21
  • 46