开发学院手机开发Android 开发 Android模拟器互发短信 阅读

Android模拟器互发短信

 2010-09-06 08:15:00 来源:WEB开发网   
核心提示:if (null != telNumStr && null != messageStr) {SmsManager smsMgr = SmsManager.getDefault();Intent i = new Intent("cc.androidos.smsdemo.IGNORE_ME");Pend

if (null != telNumStr && null != messageStr) {

SmsManager smsMgr = SmsManager.getDefault();

Intent i = new Intent("cc.androidos.smsdemo.IGNORE_ME");

PendingIntent dummyEvent = PendingIntent.getBroadcast(

SMSDemo.this, 0, i, 0);

try {

smsMgr.sendTextMessage(telNumStr, null, messageStr,

dummyEvent, dummyEvent);

} catch (Exception e) {

Log.e("SmsSending", "SendException", e);

}

} else {

showDialog(getTaskId());

}

}

});

}

/**

* get its object.

*

* @return SMSDemo

*/

public static SMSDemo getApp() {

return demo;

}

}

package cc.androidos.sms;

import android.app.Activity;

import android.app.PendingIntent;

import android.content.Intent;

import android.os.Bundle;

import android.telephony.gsm.SmsManager;

import android.util.Log;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.EditText;

/**

*

* @param demo

* :its own object.

* @param telNum

* : telephone number to send to .

* @param messageText

* : the message need to send .

* @param sendBtn

* :Button.

*

*/

public class SMSDemo extends Activity {

private static SMSDemo demo;

private EditText telNum;

private EditText messageText;

private Button sendBtn;

/**

* override the method onCreate() 1.bind the data telNum and messageText.

* 2.set the sendBtn's listener.

*/

public void onCreate(Bundle savedInstanceState) {

上一页  1 2 3 4 5 6 7  下一页

Tags:Android 模拟器 短信

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接