首页 > 代码库 > android.telephony.SmsManager 短信笔记
android.telephony.SmsManager 短信笔记
android 几种发送短信的方法
http://www.oschina.net/question/163910_27409
<
uses-permission
android:name
=
"android.permission.SEND_SMS"
></
uses-permission
>
package com.union.matchfighter;import android.app.PendingIntent;import android.telephony.SmsManager;public class PSMS { /*** * 发送信息 */ public void SendMessage(String number, String scAddress, String content, PendingIntent sentIntent, PendingIntent deliveryIntent) { SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(number, scAddress, content, sentIntent, deliveryIntent); } /*** * 根据号码和内容发送短信 */ public void SendMessage(String number , String content ) { System.out.println("1111 SendMessage"); SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(number, null, content, null, null); System.out.println("1111 SendMessage"); } static PSMS _instance ; public static PSMS getInstance() { if( _instance == null) _instance = new PSMS(); return _instance ; } /* 需要将本段放到主UI上去 public void PSMS_SendMessage( String number, String content ) { PSMS.getInstance().SendMessage(number, content); } */ }
using UnityEngine;using System.Collections;public class PSMS { /// <summary> /// 发送短信 /// </summary> /// <param name="number"></param> /// <param name="content"></param> public void sendMessage(string number, string content) { if (Application.platform == RuntimePlatform.Android) { sendMessageAndroid(number, content); } else { Debug.Log(Application.platform + " : was not fix "); } } public void sendMessageAndroid(string number, string content) { AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"); jo.Call("PSMS_SendMessage", number, content ); } static PSMS _instance; public static PSMS instance { get { if (_instance == null) _instance = new PSMS(); return _instance; } } }
android.telephony.SmsManager 短信笔记
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。