Page/Activity

Hi all,
I've just been experimenting with the ILocationManager to return my geolocation. I was initially testing this within my app.cs with no luck - It hits an exception when I run the locMgr.RequestLocationUpdates(locationProvider, 2000, 0, this);.

I then decided to move all my code into an Activity and this works.

I'm guessing this is because of the "this" key word. If I'm trying to run this outside of a class that inherits from Activity, how should this be done?

I'm assuming this code doesn't need to be within an Activity if I'm using Xamarin.Forms but please correct me if I'm wrong.
Thanks.

Posts

  • CraigDunnCraigDunn USXamarin Team Xamurai

    Can you provide more info on where this code is located? Xamarin.Forms provides a Xamarin.Forms.Forms.Context object for the Android platform. This can be used in places where an Android.Content.Context instance is required.

  • MartinCrawleyMartinCrawley USMember

    Hi @CraigDunn‌.

    Thanks for the response, but this isn't related to the context. This is related to whether or not you can use ILocationManager outside of a class that inherits from Activity. I currently see no way of doing this.

    Thanks again.

Sign In or Register to comment.