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;
}
} }