本文整理汇总了Java中com.google.android.gms.location.places.ui.PlaceAutocomplete.getStatus方法的典型用法代码示例。如果您正苦于以下问题:Java PlaceAutocomplete.getStatus方法的具体用法?Java PlaceAutocomplete.getStatus怎么用?Java PlaceAutocomplete.getStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.location.places.ui.PlaceAutocomplete
的用法示例。
在下文中一共展示了PlaceAutocomplete.getStatus方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onActivityResult
import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode){
case PLACE_AUTOCOMPLETE_REQUEST_CODE:
if (resultCode == RESULT_OK) {
Place place = PlaceAutocomplete.getPlace(getActivity(), data);
showToast(place.getAddress().toString());
Log.i("TAG", "Place: " + place.getName());
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(getActivity(), data);
// TODO: Handle the error.
Log.i("TAG", status.getStatusMessage());
showToast(status.getStatusMessage());
} else if (resultCode == RESULT_CANCELED) {
// The user canceled the operation.
showToast("Operation canceled");
}
break;
}
}
示例2: onActivityResult
import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
// Move camera to that place and add normal marker
Place place = PlaceAutocomplete.getPlace(this, data);
this.googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(place.getLatLng(), 17), 1000, null);
this.googleMap.addMarker(new MarkerOptions().position(place.getLatLng()));
// Set text on "edit text"
binding.placeSearch.setText(place.getName());
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(this, data);
Log.w(TAG, status.getStatusMessage());
} else if (resultCode == RESULT_CANCELED) {
// The user canceled the operation -- clear text
binding.placeSearch.setText("");
}
}
}
示例3: onActivityResult
import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Place pl = PlaceAutocomplete.getPlace(this, data);
location.setText(pl.getAddress());
Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status stat = PlaceAutocomplete.getStatus(this, data);
Log.d(TAG, "onActivityResult: ");
}
else if (requestCode == RESULT_CANCELED){
System.out.println("Cancelled by the user");
}
}
else
super.onActivityResult(requestCode, resultCode, data);
}
示例4: onActivityResult
import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Place pl = PlaceAutocomplete.getPlace(this, data);
location.setText(pl.getName());
currentTrip.location = pl.getName().toString();
currentTrip.lat = pl.getLatLng().latitude;
currentTrip.lng = pl.getLatLng().longitude;
currentTrip.placeId = pl.getId();
Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status stat = PlaceAutocomplete.getStatus(this, data);
Log.d(TAG, "onActivityResult: ");
}
else if (requestCode == RESULT_CANCELED){
System.out.println("Cancelled by the user");
}
}
else
super.onActivityResult(requestCode, resultCode, data);
}
示例5: onActivityResult
import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Place pl = PlaceAutocomplete.getPlace(this, data);
location.setText(pl.getName());
currentTrip.setLocation(pl.getName().toString());
currentTrip.setLat(pl.getLatLng().latitude);
currentTrip.setLng(pl.getLatLng().longitude);
currentTrip.setPlaceId(pl.getId());
Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status stat = PlaceAutocomplete.getStatus(this, data);
Log.d(TAG, "onActivityResult: ");
}
else if (requestCode == RESULT_CANCELED){
System.out.println("Cancelled by the user");
}
}
else
super.onActivityResult(requestCode, resultCode, data);
}
示例6: onActivityResult
import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
Place place = PlaceAutocomplete.getPlace(getContext(), data);
Log.i(MainActivity.TAG, "Place: " + place.getName());
weatherLat.update(place.getLatLng().latitude);
weatherLng.update(place.getLatLng().longitude);
weatherCity.update(place.getName().toString());
sWeatherCity.setSubHeaderText(weatherCity.value);
// don't change the order of the following two lines
updateWidgetProperty("lat", weatherLat.value);
updateWidgetProperty("lng", weatherLng.value);
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(getContext(), data);
// TODO: Handle the error.
Log.i(MainActivity.TAG, status.getStatusMessage());
}
}
}
示例7: onActivityResult
import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//autocompleteFragment.onActivityResult(requestCode, resultCode, data);
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Place place = PlaceAutocomplete.getPlace(this, data);
Log.i("1", "Place:" + place.toString());
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(this, data);
Log.i("1", status.getStatusMessage());
} else if (requestCode == RESULT_CANCELED) {
}
}
}
示例8: onActivityResult
import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Place place = PlaceAutocomplete.getPlace(this, data);
Toast.makeText(this, "Place picked: " + place.getName(), Toast.LENGTH_SHORT).show();
launchDisplay(place);
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(this, data);
Log.i(TAG, status.getStatusMessage());
}
}
}
示例9: onActivityResult
import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case LOCATION_NAME_REQUEST:
if (resultCode == RESULT_OK) {
Log.d(TAG, "Add city name request to queue");
Place place = PlaceAutocomplete.getPlace(getActivity(), data);
LatLng coords = place.getLatLng();
cityAddQueue.add(new CityCoordinatesModel(place.getName().toString(),
coords.latitude, coords.longitude));
if (!isRefreshing && !isAddQueueHandling) {
Log.d(TAG, "Start new city name request queue");
makeCityNameWeatherRequest();
}
isAddQueueHandling = true;
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(getActivity(), data);
Log.d(TAG, status.getStatusMessage());
}
break;
}
}
示例10: onActivityResult
import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_SELECT_PLACE) {
if (resultCode == RESULT_OK) {
Place place = PlaceAutocomplete.getPlace(this, data);
this.onPlaceSelected(place);
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(this, data);
this.onError(status);
}
}
super.onActivityResult(requestCode, resultCode, data);
}
示例11: onActivityResult
import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
/**
* 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.
}
}
}