首页 > 移动平台 > 详细

Forms Android SMS

时间:2015-08-01 01:00:14      阅读:228      评论:0      收藏:0      [点我收藏+]
技术分享
 1 forms 定义接口
 2 
 3 using System;
 4 using System.Collections;
 5 using System.Collections.Generic;
 6 
 7 namespace 
 8 {
 9     public interface ISystemSms
10     {
11         //发送短信
12         void SendSms (string num, string context);
13     }
14 }
15 
16 平台实现
17 using System;
18 using System.Collections;
19 using System.Collections.Generic;
20 using Xamarin.Forms;
21 
22 using Android.App;
23 using Android.Content;
24 using Android.Runtime;
25 using Android.Views;
26 using Android.Widget;
27 using Android.OS;
28 using Android.Telephony;
29 
30 using 
31 
32 [assembly:Dependency(typeof(SystemSms))]
33 namespace 
34 {
35     public class SystemSms : Java.Lang.Object,ISystemSms
36     {
37         public SystemSms()
38         {
39         }
40 
41         public void SendSms(string num,string context)
42         {
43             var smsUri = Android.Net.Uri.Parse("smsto:"+num);
44             var smsIntent = new Intent (Intent.ActionSendto, smsUri);
45             smsIntent.PutExtra ("sms_body", context);  
46             ((Activity)Forms.Context).StartActivity (smsIntent);
47             //Application.Context.StartActivity (smsIntent);
48 
49         }
50     }
51 
52 }
View Code

 

Forms Android SMS

原文:http://www.cnblogs.com/techidea/p/4693390.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!