当前位置: 首页>>代码示例>>C#>>正文


C# Intent.StartNewActivity方法代码示例

本文整理汇总了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);
        }
开发者ID:Jurabek,项目名称:telephony,代码行数:30,代码来源:TelephonyService.cs

示例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();
            }
        }
开发者ID:kryz,项目名称:Xamarin.Plugins,代码行数:54,代码来源:EmailTask.cs

示例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();
            }
        }
开发者ID:kryz,项目名称:Xamarin.Plugins,代码行数:15,代码来源:PhoneCallTask.cs

示例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);
        }
开发者ID:Jurabek,项目名称:telephony,代码行数:16,代码来源:TelephonyService.cs

示例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();
            }
        }
开发者ID:pacificIT,项目名称:Xamarin.Plugins-1,代码行数:17,代码来源:SmsTask.cs

示例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();
            }
        }
开发者ID:kryz,项目名称:Xamarin.Plugins,代码行数:18,代码来源:SmsTask.cs

示例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();
            }
        }
开发者ID:pacificIT,项目名称:Xamarin.Plugins-1,代码行数:44,代码来源:EmailTask.cs


注:本文中的Android.Content.Intent.StartNewActivity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。