Java Code Examples for com.google.android.gms.location.places.ui.PlaceAutocomplete#RESULT_ERROR

The following examples show how to use com.google.android.gms.location.places.ui.PlaceAutocomplete#RESULT_ERROR . 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: 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.
        }
    }
}