1.直接跳转到goole原生的sms进行短信的编辑:
alternateIntent = new Intent(Intent.ACTION_SENDTO,
Uri.fromParts(ContactsUtils.SCHEME_SMSTO, phone.getNumber(), null));//跳转至短信并自动填充收件人
//alternateIntent.setComponent(new ComponentName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity"));//如果要跳转到指定的短信模块,加上此句即设置跳转
其中跳转方式包含:
ComponentName com = new ComponentName(MainActivity.this,MyActivity.class);//first
ComponentName com = new ComponentName
("com.example.testcomponent","com.example.testcomponent.MyActivity");//second
<pre>
button.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent();
ComponentName com = new ComponentName(
"com.example.testcomponent",
"com.example.testcomponent.MyActivity");
intent.setComponent(com);
String s = "This is a Test.";
intent.putExtra("id", s);
startActivity(intent);
}
});
Intent intent = getIntent();
String str = intent.getStringExtra("id");
ComponentName com = intent.getComponent();
String pkgName = com.getPackageName();
String className = com.getClassName();
text.setText(str + "\n" + pkgName + "\n" + className);
</pre>
2.跳转到google短信中并携带内容:
<pre>
String defaultSmsPackageName = Telephony.Sms.getDefaultSmsPackage(mContext);
Intent intent = new Intent(Intent.ACTION_SEND);//根据sdk版本,文献这查说是4.4之后用此action,
intent.setType("text/plain");//设置携带内容的格式
intent.putExtra(Intent.EXTRA_TEXT, localSmsContactComposer.getData());
if (defaultSmsPackageName != null){
intent.setPackage(defaultSmsPackageName);//指定报名后可以直接跳转到默认,而不是出现多项选择
}
try {
startActivity(intent);
return;
} catch (ActivityNotFoundException localActivityNotFoundException) {
Log.e(TAG, "No activity found for intent: " + intent);
}
</pre>
参考uri:http://blog.csdn.net/q931368239/article/details/50512006