Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share via SMS only

Tags:

android

sms

send

My app has an image button which on click should send a piece of text via SMS only. How do i get my app to do that? Please help.

I also want to the user to be able to choose a contact from the list of contacts on his device.

Jumana

like image 648
Jumana Avatar asked Dec 01 '22 00:12

Jumana


1 Answers

Steps to enable sending sms:

1- In android-manifest, add sending sms permission as below:

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

2- In yout Activity add this method:

public void sendSms(final String receiverNumber, final String smsBody) {
    SmsManager smsManager = SmsManager.getDefault();
    smsManager.sendTextMessage(receiverNumber, null, smsBody, null, null);        
}
like image 193
Ali Behzadian Nejad Avatar answered Dec 06 '22 01:12

Ali Behzadian Nejad