i'm trying to test the DependencyService of my app by displaying an alert dialog from an android project when i press a button i created in the share code project.
When i try to set the Context property in the 'AlertDialog.Builder' by entering 'this' in the parenthesis i get this error: "Cannot convert from 'CallDiverter2.Droid.CallDiverter_Android' to 'Android.Content.Context'.
Also the namespace is decorated with: '[assembly: Dependency(typeof(CallDiverter_Android))]' if its matter.
this is the function in the android project i want to call using the DependecyService:
public class CallDiverter_Android : ICallDiverter
{
public void DivertCall(string callForwardString)
{
//Divert call code
//String callForwardString = "**21*1234567890#";
//Intent callIntent = new Intent(Intent.ActionDial); // ACTION_CALL
//Android.Net.Uri uri = Android.Net.Uri.Parse(callForwardString);
//callIntent.SetData(uri);
//Android.App.Application.Context.StartActivity(callIntent);
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
AlertDialog alert = dialog.Create();
alert.SetTitle("Title");
alert.SetMessage("Simple Alert");
alert.SetButton("OK", (s, ev) =>
{
alert.SetMessage("This is an alert message");
});
alert.Show();
}
public void StopCallDiverting()
{
//Stop the call diverting action
}
}
How should i fix this so i can successfully test the dependencyService?