Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: handover sms to default application

Tags:

android

Please guide, in Android how can I pass my string (less then 160 char) to the default built-in SMS applicaion or queue, which will complete the process.

I mean, from my activity I want to call a built-in SMS application and pass my SMS string to that, then the built-in application will be responsible to rest of activity like SMS resending, etc.

like image 217
harisali Avatar asked Jun 06 '26 05:06

harisali


2 Answers

To call the default sms application, with sms body and phone number :

Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "sms:" + phoneNumber ) );
intent.putExtra( "sms_body", smsBody );
context.startActivity( intent );

By default I mean the application chosen by the user. Actually it's better to start the default sms application than the built-in because you have to respect the user choice. If the device owner has chosen ChompSms as default SMS application, he will prefer your application launches ChompSms and not an other.

like image 69
tbruyelle Avatar answered Jun 07 '26 20:06

tbruyelle


To call the default sms application, with sms body and phone number :

Uri uri = Uri.parse("smsto:123456789");   
    Intent it = new Intent(Intent.ACTION_SENDTO, uri);   
    it.putExtra("sms_body", "The Hello How R U...");   
    startActivity(it); 
like image 38
J_K Avatar answered Jun 07 '26 18:06

J_K