Can Not Cast Context Into Activity Xamarin
I have an issue in xamarin, and I need some help, please From xamarin tutorial, I wish to launch a phone call thanks to a DependencyService. Here is the service implementation for
Solution 1:
I have just found the solution.
I had to take the context with
var context = Xamarin.Forms.Forms.Context;
instead of
var context = Android.App.Application.Context;
After that, cast works nicely
Thanks everybody
Solution 2:
Try this
(YourActivityName)Forms.Context;
for example:
var activity = (YourActivityName)Forms.Context;
Solution 3:
If you are in Activity.
You are casting Application context.
var context = Android.App.Application.Context;
Replace it with below
var context = android.content.Context;
If you are working in Service then you can ask for permission from where you are calling your service.
Post a Comment for "Can Not Cast Context Into Activity Xamarin"