Android tutorial: Send SMS programatically

4 05 2013

SmsManager has a method that is sending SMS message completely without user’s interaction needed. If You need to send SMS from your code:

1. Use SmsManager

Add these lines to your app

import android.telephony.SmsManager;

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("123456789", null, "sms message", null, null);

You can replace these nulls with Intents (according to documentation) that will be fired up when SMS is delivered / sent / failed to send. In basic case it is optional and can be null.

2. request permissions in AndroidManifest.xml

Add these lines to Manifest:

<uses-permission android:name="android.permission.SEND_SMS" />


Remember to have active SIM card in your device when you want to send SMS :)

Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!




9 responses

31 08 2013
iOS tutorial: Send SMS programmatically | Looks OK!

[…] Android the situation is different. Developer is free to use all phone features including sending SMS in background, listening for incoming SMS, calls, initiating calls etc. It trusts user that if he install app he […]

19 03 2014

what is the need of having working sim card while we are sending message by application.

Reply I am waiting

19 03 2014
Jacek Milewski

and how are you going to send SMS otherwise?…

Of course the code will work withot SIM card inserted but SMS obviously will not be sent

19 03 2014

what i want is, user will insert his/her number, and my app should get the no and send sms to the same number so that we can get back this number from the user to verify . means app should send verification code via sms not user, still require the working sim?

19 03 2014
Jacek Milewski

yes. you need SIM card to send sms. even to yourself – it involves the cellular network.

what’s more… rethink your application flow and logic. Such logic seems irrational to me

22 03 2014
Shani Goriwal

Thanks alot Mr. Jacek i got solved issue means now i am able to send sms. but still wat i want that when i prompt user to send msg on their number for verification purpuse the name of the sender should be the “App Name” not the user’s number. currently the name of the sender is user’s own number.
Do you have any Idea about this please help I am waiting for your response.


22 03 2014
Jacek Milewski

It’s possible by adding the number to the address book, so it will appear with the desired name

such sender modification is doable only by Network operators. You cannot modify it afaik

14 09 2015

Thanks for the code.

14 06 2018
Molana Softwares

sending sms by sim 1 or 2 programmatically…?

Give Your feedback:

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: