Android模拟器互发短信
2010-09-06 08:15:00 来源:WEB开发网}
Log.e("message", sb.toString());
/**
* call an intent to start the activity DisplayMessage with variable
* message data.
*/
Intent i = new Intent(context, DisplayMessage.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra("message", sb.toString());
context.startActivity(i);
}
}
显示短信的Activity:
Java代码
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;
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(":");
更多精彩
赞助商链接