• 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;
            }
        }
     
    }
    
  • 相关阅读:
    041_form表单重置数据reset()
    040_下拉列表的显示与提交数值时,需要用到转义字符
    039_如何选取checkbox的id值?
    011_表单数据非空验证
    010_@ResposBody错误
    010_页面单击按钮失灵
    使用Maven创建 web项目
    java设计模式(八) 适配器模式
    设计模式 6大设计原则
    Java设计模式(七) 模板模式-使用钩子
  • 原文地址:https://www.cnblogs.com/didiaodexi/p/4046345.html
Copyright © 2020-2023  润新知