发送带有预设电话号码的短信

时间:2012-03-06 18:13:46

标签: android android-intent sms

我想发送短信,此代码段有效:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "Check out this Punchit app!
https://market.android.com/details?id=com.punchit");  
sendIntent.setType("vnd.android-dir/mms-sms"); 
startActivity(sendIntent);

现在我想预设电话号码并尝试以下两种方法:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setData(Uri.parse("tel:9999999999" ));

sendIntent.putExtra(android.content.Intent.EXTRA_PHONE_NUMBER, "9999999999");

这两个陈述都不起作用,那么预设电话号码的正确语法是什么?

1 个答案:

答案 0 :(得分:0)

测试如下:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "Hello1");
sendIntent.putExtra("address", "12345");
sendIntent.setType("vnd.android-dir/mms-sms")