Slide 20
Slide 20 text
All Rights Reserved. Copyright © CRESCO LTD. 20
݅ৄࡉϖʔδ<ϝʔϧ࿈ܞػೳ Android>
PCLଆʹϝʔϧػೳͷΠϯλʔϑΣʔεΛ࣮
public interface IMailOpener
{
void OpenMail(object context, string to, string subject, string body);
}
AndroidଆʹDependencyServiceΛܦ༝ͯ͠ݺͼग़͞ΕΔOpenMailϝιουΛఆٛ
[assembly: Dependency (typeof (MailOpener_Droid))]
namespace HogeHoge.Droid
{
public class MailOpener_Droid : IMailOpener
{
public MailOpener_Droid (){}
public void OpenMail(object context, string to, string subject, string body){
Intent intent = new Intent(Intent.ActionSend);
intent.SetType("text/html");
intent.PutExtra(Intent.ExtraEmail,new String[]{to});
intent.PutExtra(Intent.ExtraSubject, subject);
intent.PutExtra(Intent.ExtraText, body);
var currentActivity = context as Activity;
currentActivity.StartActivity(Intent.CreateChooser(intent, "Send Email"));
}
}
}
PCLଆͰͷݺͼग़͠ྫ
void OnMailButtonClicked(object sender, EventArgs args) {
ɹɹobject context = MailButton.myContext;
ɹɹDependencyService.Get().OpenMail(context, myToAddress, mySubject, myBody);
}