如何执行默认短信应用程序?

时间:2011-03-27 11:30:04

标签: android android-intent sms

我注册了我的接收器以获取短信。当我收到短信时,如何执行手机的默认短信应用?

我可以使用意图发送操作来启动默认的短信应用吗?

2 个答案:

答案 0 :(得分:1)

可以通过几种不同的方式完成。这是一个:

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "Content of the SMS goes here..."); 
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);

答案 1 :(得分:0)

Here "number" is an array of strings with the numbers of contacts to whom you want to send sms to and "älldetails" is teh string you want to send. 


 String n = "";
for(int i = 0; i<sizesf ;i++)
{
        if(i == (sizesf-1))
        {

            n = n + number[i];
        }

        else 
            n = n + number[i] + ";";

}  


Log.d("numbers in intent", n);

Intent smsIntent = new Intent( Intent.ACTION_VIEW, Uri.parse( "smsto:"+ n) );
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address", n );
smsIntent.putExtra("sms_body",alldetails);
startActivity(smsIntent);

}