开发者

How can I execute default sms app?

I registered my receiver to get SMS. When I receive SMS's, how can I execute the phone's default SMS app?

Can I use the in开发者_开发技巧tent send action to start the default SMS app?


It can be done in a couple of different ways. Here's one:

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


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

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜