Intent Виджет Google PlaceAutocomplete сразу закрывается после открытия
Вызываю PlaceAutocomplete через клик по ImageView
//....
Buttest = FindViewById<ImageView>(Resource.Id.imageSertch);
Buttest.Click += PlaceButonClic;
}
private void PlaceButonClic(object sender, EventArgs e)
{
Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.ModeOverlay).Build(this);
StartActivityForResult(intent, 1);
}
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if(requestCode==1)
if (resultCode == Result.Ok)
{
var place = Android.Gms.Location.Places.UI.PlaceAutocomplete.GetPlace(this, data);
DistanceText.Text = place.NameFormatted.ToString();
}
}
Но после открытие сразу закрывается
в манифесте ключ <meta-data android:name="com.google.android.geo.v2.API_KEY" android:value="AIzaSyDdrdvoOfj-ZcLdZ-*****************" />
Подозреваю что проблема в ключе, но до сих пор не нашел информации
Как я могу исправить моментальное закрытие
Ответы (1 шт):
Автор решения: Walker
→ Ссылка
Летом 2019 года система была обновлена и теперь нужно использовать
Xamarin.Google.Android.Places
Xamarin.Android.Volley
if (!PlacesApi.IsInitialized)
{
PlacesApi.Initialize(this, "Api код");
}
Buttest.Click += delegate
{
List<Place.Field> Fields = new List<Place.Field>();
Fields.Add(Place.Field.Id);
Fields.Add(Place.Field.Name);
Fields.Add(Place.Field.LatLng);
Fields.Add(Place.Field.Address);
string cantriuser = Resources.GetString(Resource.String.Country);
var bount = RectangularBounds.NewInstance( new LatLng(MyLatitude - 2, MyLongitude - 2),new LatLng(MyLatitude + 2, MyLongitude + 2));
var intent = new Autocomplete.IntentBuilder(AutocompleteActivityMode.Overlay, Fields)/*.SetCountry(cantriuser)*/;
intent.SetLocationRestriction(bount);//Ограничение територии выдачи
StartActivityForResult(intent.Build(this), 1);
};
