Android模拟器互发短信
2010-09-06 08:15:00 来源:WEB开发网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);
messageText.append(" ");
messageReplyText.setText("");
} catch (Exception e) {
Log.e("SmsSending", "SendException", e);
}
bar.setVisibility(ProgressBar.INVISIBLE);
}
});
}
/**
* get the name by his tel number.
*
* @param telNum
* @return
*/
private String getNameByIdTelnum(String telNum) {
Cursor mCursor = this.getContentResolver().query(Uri.parse("telNum"),
null, null, null, null);
String result = mCursor.getColumnName(1);
Log.e("test name", result);
return "";
// mCursor.getColumnIndex("Sun");
}
}
package cc.androidos.sms;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.gsm.SmsManager;
import android.util.Log;
赞助商链接