本文整理汇总了C#中Android.Content.Intent.StartNewActivity方法的典型用法代码示例。如果您正苦于以下问题:C# Intent.StartNewActivity方法的具体用法?C# Intent.StartNewActivity怎么用?C# Intent.StartNewActivity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Content.Intent
的用法示例。
在下文中一共展示了Intent.StartNewActivity方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComposeEmail
public virtual Task ComposeEmail(IEmailMessage emailMessage)
{
if (!CanComposeEmail)
{
throw new FeatureNotAvailableException();
}
var intent = new Intent(Intent.ActionSend);
intent.PutExtra(Intent.ExtraEmail, emailMessage.To.Select(x => x.Address).ToArray());
intent.PutExtra(Intent.ExtraCc, emailMessage.Cc.Select(x => x.Address).ToArray());
intent.PutExtra(Intent.ExtraBcc, emailMessage.Bcc.Select(x => x.Address).ToArray());
intent.PutExtra(Intent.ExtraTitle, emailMessage.Subject);
if (emailMessage.IsHTML)
{
intent.PutExtra(Intent.ExtraText, Html.FromHtml(emailMessage.Body));
}
else
{
intent.PutExtra(Intent.ExtraText, emailMessage.Body);
}
intent.SetType("message/rfc822");
intent.StartNewActivity();
return Task.FromResult(true);
}
示例2: SendEmail
public void SendEmail(IEmailMessage email)
{
// NOTE: http://developer.xamarin.com/recipes/android/networking/email/send_an_email/
if (email == null)
throw new ArgumentNullException("email");
if (CanSendEmail)
{
// NOTE: http://developer.android.com/guide/components/intents-common.html#Email
string intentAction = Intent.ActionSend;
if (email.Attachments.Count > 1)
intentAction = Intent.ActionSendMultiple;
Intent emailIntent = new Intent(intentAction);
emailIntent.SetType("message/rfc822");
if (email.Recipients.Count > 0)
emailIntent.PutExtra(Intent.ExtraEmail, email.Recipients.ToArray());
if (email.RecipientsCc.Count > 0)
emailIntent.PutExtra(Intent.ExtraCc, email.RecipientsCc.ToArray());
if (email.RecipientsBcc.Count > 0)
emailIntent.PutExtra(Intent.ExtraBcc, email.RecipientsBcc.ToArray());
emailIntent.PutExtra(Intent.ExtraSubject, email.Subject);
// NOTE: http://stackoverflow.com/questions/13756200/send-html-email-with-gmail-4-2-1
if (((EmailMessage)email).IsHtml)
emailIntent.PutExtra(Intent.ExtraText, Html.FromHtml(email.Message));
else
emailIntent.PutExtra(Intent.ExtraText, email.Message);
if (email.Attachments.Count > 0)
{
var uris = new List<IParcelable>();
foreach (var attachment in email.Attachments)
{
var uri = Android.Net.Uri.Parse("file://" + ((EmailAttachment)attachment).FilePath);
uris.Add(uri);
}
if (uris.Count > 1)
emailIntent.PutParcelableArrayListExtra(Intent.ExtraStream, uris);
else
emailIntent.PutExtra(Intent.ExtraStream, uris[0]);
}
emailIntent.StartNewActivity();
}
}
示例3: MakePhoneCall
public void MakePhoneCall(string number, string name = null)
{
if (string.IsNullOrWhiteSpace(number))
throw new ArgumentException("number");
if (CanMakePhoneCall)
{
var phoneNumber = PhoneNumberUtils.FormatNumber(number);
Uri telUri = Uri.Parse("tel:" + phoneNumber);
var dialIntent = new Intent(Intent.ActionDial, telUri);
dialIntent.StartNewActivity();
}
}
示例4: ComposeSMS
public virtual Task ComposeSMS(string recipient, string message = null)
{
if (!CanComposeSMS)
{
throw new FeatureNotAvailableException();
}
var uri = Uri.Parse(string.Format("sms:{0}", recipient));
var intent = new Intent(Intent.ActionSendto, uri);
intent.PutExtra("sms_body", message ?? string.Empty);
intent.StartNewActivity();
return Task.FromResult(true);
}
示例5: SendSms
public void SendSms(string recipient, string message)
{
if (string.IsNullOrWhiteSpace(recipient))
throw new ArgumentNullException("recipient");
if (string.IsNullOrWhiteSpace(message))
throw new ArgumentNullException("message");
if (CanSendSms)
{
var smsUri = Uri.Parse("smsto:" + recipient);
var smsIntent = new Intent(Intent.ActionSendto, smsUri);
smsIntent.PutExtra("sms_body", message);
smsIntent.StartNewActivity();
}
}
示例6: SendSms
public void SendSms(string recipient = null, string message = null)
{
message = message ?? string.Empty;
if (CanSendSms)
{
Uri smsUri;
if (!string.IsNullOrWhiteSpace(recipient))
smsUri = Uri.Parse("smsto:" + recipient);
else
smsUri = Uri.Parse("smsto:");
var smsIntent = new Intent(Intent.ActionSendto, smsUri);
smsIntent.PutExtra("sms_body", message);
smsIntent.StartNewActivity();
}
}
示例7: SendEmail
public void SendEmail(IEmailMessage email)
{
// NOTE: http://developer.xamarin.com/recipes/android/networking/email/send_an_email/
if (email == null)
throw new ArgumentNullException("email");
if (email.Attachments.Count > 1)
throw new NotSupportedException("Cannot send more than once attachment for Android");
if (CanSendEmail)
{
Intent emailIntent = new Intent(Intent.ActionSend);
emailIntent.SetType("message/rfc822");
if (email.Recipients.Count > 0)
emailIntent.PutExtra(Intent.ExtraEmail, email.Recipients.ToArray());
if (email.RecipientsCc.Count > 0)
emailIntent.PutExtra(Intent.ExtraCc, email.RecipientsCc.ToArray());
if (email.RecipientsBcc.Count > 0)
emailIntent.PutExtra(Intent.ExtraBcc, email.RecipientsBcc.ToArray());
emailIntent.PutExtra(Intent.ExtraSubject, email.Subject);
// NOTE: http://stackoverflow.com/questions/13756200/send-html-email-with-gmail-4-2-1
if (((EmailMessage) email).IsHtml)
emailIntent.PutExtra(Intent.ExtraText, Html.FromHtml(email.Message));
else
emailIntent.PutExtra(Intent.ExtraText, email.Message);
if (email.Attachments.Count > 0)
{
var attachment = (EmailAttachment) email.Attachments[0];
var uri = Android.Net.Uri.Parse("file://" + attachment.FilePath);
emailIntent.PutExtra(Intent.ExtraStream, uri);
}
emailIntent.StartNewActivity();
}
}