I am just about to use the "FusedLocationProvider" from the xamarin sample. When I start it up, it works. It is just one activity and one layout file.
I now added a new class to my project and called it "FindTheLocationNEW" into which I simply copy-pasted everything from the xamarin sample. Now, everything seems to work fine after a few adjustments with the layout file (nothing serious) and only the "this" keyword says:
Cannot convert from "FusedLocationProvider.MainActivity" to "Android.App.PendingIntent".
However, this did work when it was a standalone activity. So I am guessing, the "this" keyword is getting a wrong context.
A bit of the code:
namespace FusedLocationProvider
{
[Activity(Label = "FusedLocationProvider", MainLauncher = true)]
public class MainActivity : Activity, GoogleApiClient.IConnectionCallbacks,
GoogleApiClient.IOnConnectionFailedListener, Android.Gms.Location.ILocationListener
{
button2.Click += async delegate {
if (apiClient.IsConnected)
{
button2.Text = "Requesting Location Updates";
// Setting location priority to PRIORITY_HIGH_ACCURACY (100)
locRequest.SetPriority(100);
// Setting interval between updates, in milliseconds
// NOTE: the default FastestInterval is 1 minute. If you want to receive location updates more than
// once a minute, you _must_ also change the FastestInterval to be less than or equal to your Interval
locRequest.SetFastestInterval(500);
locRequest.SetInterval(1000);
Log.Debug("LocationRequest", "Request priority set to status code {0}, interval set to {1} ms",
locRequest.Priority.ToString(), locRequest.Interval.ToString());
// pass in a location request and LocationListener
await LocationServices.FusedLocationApi.RequestLocationUpdates(apiClient, locRequest, this); // THIS IS WHERE IT IS NOT WORKING!!!
// In OnLocationChanged (below), we will make calls to update the UI
// with the new location data
}
else
{
Log.Info("LocationClient", "Please wait for Client to connect");
}
};
}
Any help would be awesome!