com.google.android.gms.location.places.ui.PlaceAutocomplete Java Examples

The following examples show how to use com.google.android.gms.location.places.ui.PlaceAutocomplete. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SelfRouteDetailActivity.java    From kute with Apache License 2.0 6 votes vote down vote up
private void configurePlace(int requestCode,int resultCode,Intent data){
    if (resultCode == RESULT_OK) {
        Place place = PlaceAutocomplete.getPlace(this, data);
        if(requestCode==PLACE_AUTOCOMPLETE_REQUEST_CODE_SOURCE) {
            source_address=place.getAddress().toString();
            from.setText(place.getAddress());
            source_cords=Double.toString(place.getLatLng().latitude)+","+Double.toString(place.getLatLng().longitude);
            source_name_string=place.getName().toString();
        }
        else if(requestCode==PLACE_AUTOCOMPLETE_REQUEST_CODE_DESTINATION) {
            destination_address=place.getAddress().toString();
            to.setText(place.getAddress());
            destination_cords=Double.toString(place.getLatLng().latitude)+","+Double.toString(place.getLatLng().longitude);
            destination_name_string=place.getName().toString();
        }
        Log.i(TAG, "Place: " + place.getAddress());
    } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
        Status status = PlaceAutocomplete.getStatus(this, data);
        // TODO: Handle the error.
        Log.i(TAG, status.getStatusMessage());

    } else if (resultCode == RESULT_CANCELED) {
        // The user canceled the operation.
    }

}
 
Example #2
Source File: AddRouteActivity.java    From kute with Apache License 2.0 6 votes vote down vote up
private void configurePlace(int requestCode,int resultCode,Intent data){
    if (resultCode == RESULT_OK) {
        Place place = PlaceAutocomplete.getPlace(this, data);
        if(requestCode==PLACE_AUTOCOMPLETE_REQUEST_CODE_SOURCE) {
            source.setText(place.getAddress());
            source_cords=Double.toString(place.getLatLng().latitude)+","+Double.toString(place.getLatLng().longitude);
            source_name_string=place.getName().toString();
        }
        else if(requestCode==PLACE_AUTOCOMPLETE_REQUEST_CODE_DESTINATION) {
            destination.setText(place.getAddress());
            destination_cords=Double.toString(place.getLatLng().latitude)+","+Double.toString(place.getLatLng().longitude);
            destination_name_string=place.getName().toString();
        }
        Log.i(TAG, "Place: " + place.getAddress());
    } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
        Status status = PlaceAutocomplete.getStatus(this, data);
        // TODO: Handle the error.
        Log.i(TAG, status.getStatusMessage());

    } else if (resultCode == RESULT_CANCELED) {
        // The user canceled the operation.
    }

}
 
Example #3
Source File: StartRide.java    From kute with Apache License 2.0 6 votes vote down vote up
private void configurePlace(int requestCode,int resultCode,Intent data){
    if (resultCode == RESULT_OK) {
        Place place = PlaceAutocomplete.getPlace(this, data);
        if(requestCode==PLACE_AUTOCOMPLETE_REQUEST_CODE_SOURCE) {
            source_string=place.getName().toString();
            source_text.setText(source_string);
            source_cords=Double.toString(place.getLatLng().latitude)+","+Double.toString(place.getLatLng().longitude);
            source_address=place.getAddress().toString();
        }
        else if(requestCode==PLACE_AUTOCOMPLETE_REQUEST_CODE_DESTINATION) {
            destination_string=place.getName().toString();
            destination_text.setText(destination_string);
            destination_cords=Double.toString(place.getLatLng().latitude)+","+Double.toString(place.getLatLng().longitude);
            destination_address=place.getAddress().toString();
        }
        Log.i(TAG, "Place: " + place.getAddress());
    } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
        Status status = PlaceAutocomplete.getStatus(this, data);
        // TODO: Handle the error.
        Log.i(TAG, status.getStatusMessage());

    } else if (resultCode == RESULT_CANCELED) {
        // The user canceled the operation.
    }

}
 
Example #4
Source File: AddTrip.java    From kute with Apache License 2.0 6 votes vote down vote up
private void configurePlace(int requestCode,int resultCode,Intent data){
    if (resultCode == RESULT_OK) {
        Place place = PlaceAutocomplete.getPlace(this, data);
        if(requestCode==PLACE_AUTOCOMPLETE_REQUEST_CODE_SOURCE) {
            source_string=place.getName().toString();
            source.setText(place.getAddress());
            source_cords=Double.toString(place.getLatLng().latitude)+","+Double.toString(place.getLatLng().longitude);
            source_address=place.getAddress().toString();
        }
        else if(requestCode==PLACE_AUTOCOMPLETE_REQUEST_CODE_DESTINATION) {
            destination_string=place.getAddress().toString();
            destination.setText(place.getAddress());
            dest_cords=Double.toString(place.getLatLng().latitude)+","+Double.toString(place.getLatLng().longitude);
            destination_address=place.getAddress().toString();
        }
        Log.i(TAG, "Place: " + place.getAddress());
    } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
        Status status = PlaceAutocomplete.getStatus(this, data);
        // TODO: Handle the error.
        Log.i(TAG, status.getStatusMessage());

    } else if (resultCode == RESULT_CANCELED) {
        // The user canceled the operation.
    }

}
 
Example #5
Source File: PlaceSearchFragment.java    From Place-Search-Service with MIT License 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
        Place place = PlaceAutocomplete.getPlace(context, data);
        Log.e("lingquan", "the task is " + resultCode + " " + requestCode + "     " + PlaceAutocomplete.getPlace(context, data).toString());
        oldLocation = place.getAddress().toString();
        mPlaceSearchLocation.setText(place.getAddress());
    }
}
 
Example #6
Source File: NewOrderInteractor.java    From CourierApplication with Mozilla Public License 2.0 5 votes vote down vote up
public void onActivityResultSuccesful(int requestCode, Intent data) {
    if(requestCode == 1) {
        onAddressFromReceived(String.valueOf(PlaceAutocomplete.getPlace(mFragmentActivity, data).getAddress()));
        onFromLatLngReceived(PlaceAutocomplete.getPlace(mFragmentActivity, data).getLatLng().latitude,
                PlaceAutocomplete.getPlace(mFragmentActivity, data).getLatLng().longitude);
        sendFromAddressString();
    } else if(requestCode == 2) {
        onAddressToReceived(String.valueOf(PlaceAutocomplete.getPlace(mFragmentActivity, data).getAddress()));
        onToLatLngReceived(PlaceAutocomplete.getPlace(mFragmentActivity, data).getLatLng().latitude,
                PlaceAutocomplete.getPlace(mFragmentActivity, data).getLatLng().longitude);
        sendToAddressString();
    }
}
 
Example #7
Source File: MainActivity.java    From android-play-places with Apache License 2.0 5 votes vote down vote up
/**
 * Called after the autocomplete activity has finished to return its result.
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Check that the result was from the autocomplete widget.
    if (requestCode == REQUEST_CODE_AUTOCOMPLETE) {
        if (resultCode == RESULT_OK) {
            // Get the user's selected place from the Intent.
            Place place = PlaceAutocomplete.getPlace(this, data);
            Log.i(TAG, "Place Selected: " + place.getName());

            // Format the place's details and display them in the TextView.
            mPlaceDetailsText.setText(formatPlaceDetails(getResources(), place.getName(),
                    place.getId(), place.getAddress(), place.getPhoneNumber(),
                    place.getWebsiteUri()));

            // Display attributions if required.
            CharSequence attributions = place.getAttributions();
            if (!TextUtils.isEmpty(attributions)) {
                mPlaceAttribution.setText(Html.fromHtml(attributions.toString()));
            } else {
                mPlaceAttribution.setText("");
            }
        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status status = PlaceAutocomplete.getStatus(this, data);
            Log.e(TAG, "Error: Status = " + status.toString());
        } else if (resultCode == RESULT_CANCELED) {
            // Indicates that the activity closed before a selection was made. For example if
            // the user pressed the back button.
        }
    }
}