码迷,mamicode.com
首页 > 移动开发 > 详细

android.telephony.SmsManager 短信笔记

时间:2014-10-23 17:34:02      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:android   blog   http   color   io   os   ar   java   for   

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 短信笔记

标签:android   blog   http   color   io   os   ar   java   for   

原文地址:http://www.cnblogs.com/didiaodexi/p/4046345.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!