Hi,
I created a simple Xamarin.Forms dependency service in Android to launch the email composer but I'm getting a java security exception when executing the code below. I checked but there's no specific Android permission for writing emails... x
Any suggestions appreciated.
Thanks!
[assembly: Xamarin.Forms.Dependency (typeof (MyApp.Droid.Interfaces.EmailSender_Android))]
namespace MyApp.Droid.Interfaces
{
public class EmailSender_Android : Java.Lang.Object, IEmailSender
{
// Constructor
public EmailSender_Android() { }
// Send Email
public bool Send(string recipientEmailAddress, string subject, string message) {
bool ret = true;
// Get the context
var ctx = Forms.Context;
// Create Email Intent
var intent = new Intent (Intent.ActionSend);
// Set Recipient
intent.PutExtra(Intent.ExtraEmail, new string[] { recipientEmailAddress });
// Set Email Subject
intent.PutExtra(Intent.ExtraSubject, subject);
try {
Forms.Context.StartActivity(intent);
ret = true;
} catch (Exception ex) {
Console.WriteLine (ex.Message);
ret = false;
}
return ret;
}