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

Android模拟器互发短信

 2010-09-06 08:15:00 来源:WEB开发网   
核心提示:import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.EditText;import android.widget.ProgressBar;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.EditText;

import android.widget.ProgressBar;

public class DisplayMessage extends Activity {

private EditText messageText;

private EditText messageReplyText;

private Intent intent;

private String telNum;

private String message;

private Button replyBtn;

private ProgressBar bar;

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.receiver);

messageText = (EditText) findViewById(R.id.message_get);

messageReplyText = (EditText) findViewById(R.id.message_reply);

replyBtn = (Button) findViewById(R.id.reply_button);

bar = (ProgressBar) findViewById(R.id.bar);

bar.setVisibility(ProgressBar.INVISIBLE);

intent = getIntent();

String data = intent.getStringExtra("message");

String[] str = data.split(":");

if (str.length == 2) {

telNum = str[0];

message = str[1];

}

messageText.append(data);

messageText.append(" ");

// messageText.append(" ");

replyBtn.setOnClickListener(new OnClickListener() {

public void onClick(View v) {

bar.setVisibility(ProgressBar.VISIBLE);

String replyMessage = messageReplyText.getText().toString();

SmsManager smsMgr = SmsManager.getDefault();

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

PendingIntent dummyEvent = PendingIntent.getBroadcast(

DisplayMessage.this, 0, i, 0);

try {

smsMgr.sendTextMessage(telNum, null, replyMessage,

dummyEvent, dummyEvent);

messageText.append(replyMessage);

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

Tags:Android 模拟器 短信

编辑录入:coldstar [复制链接] [打 印]
赞助商链接