I want to develop a project to send text messages in android using sendTextMessage()
from android.telephony.SmsManager
. When the message is sent a prompt appears. I want to know where can I find that code?
Asked
Active
Viewed 68 times
-5
-
2Why you are asking for code with out showing what you have tried ?? – Sree Apr 25 '14 at 04:32
2 Answers
1
try below code:-
buttonSend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String phoneNo = textPhoneNo.getText().toString();
String sms = textSMS.getText().toString();
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, sms, null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again later!",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});

domdomcodecode
- 2,355
- 4
- 19
- 27

duggu
- 37,851
- 12
- 116
- 113
0
I believe you have not search it:
Question : Sending text messages programmatically in android already exists.
you can try this code also:
public void sendLongSMS() {
String phoneNumber = "0123456789";
String message = "Hello World! Now we are going to demonstrate " +
"how to send a message with more than 160 characters from your Android application.";
SmsManager smsManager = SmsManager.getDefault();
ArrayList<String> parts = smsManager.divideMessage(message);
smsManager.sendMultipartTextMessage(phoneNumber, null, parts, null, null);
}
Code for Toast(prompt)
Toast.makeText(getContext(), "Your message",Toast.LENGTH_LONG).show();
Read this : What types of questions should I avoid asking? before asking question here.
-
I know the code to send sms from android and its working properly, I want to make some changes in android.telephony.SmsManager file so please suggest how to do it, I added that file in my project but its not working. – LUNA Apr 30 '14 at 06:16