Created
May 22, 2018 19:19
-
-
Save gaurav-gogia/c801f17e25fd1017ad897aa4273e748d to your computer and use it in GitHub Desktop.
Trying to use "FusedLocationProviderClient" in Xamarin.Android to get user location.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Android.Locations; | |
using Android.App; | |
using Android.OS; | |
using Android.Runtime; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Android.Util; | |
using Android.Widget; | |
using Android.Gms.Common; | |
using Android.Gms.Location; | |
namespace locator | |
{ | |
[Activity(Label = "locator", MainLauncher = true)] | |
public class MainActivity : Activity | |
{ | |
FusedLocationProviderClient fusedLocationProvider; // "FusedLocationProviderClient" does not exist in current context. | |
protected override void OnCreate(Bundle savedInstanceState) | |
{ | |
base.OnCreate(savedInstanceState); | |
SetContentView(Resource.Layout.Main); | |
} | |
private bool PlayServicesStatus() | |
{ | |
var result = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(this); | |
if (result == ConnectionResult.Success) | |
return true; | |
if (GoogleApiAvailability.Instance.IsUserResolvableError(result)) | |
{ | |
string error = GoogleApiAvailability.Instance.GetErrorString(result); | |
Toast.MakeText(this, error, ToastLength.Short).Show(); | |
} | |
return false; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment