简体   繁体   中英

send sms with a preset phone number

I want to send an sms message and this code snippet works:

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);

Now I want to preset the phone number and tried both of the following:

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

and

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

Neither of these two statements work, so what is the correct syntax for presetting a phone number?

test as follows:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM