-5

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?

Ravi
  • 34,851
  • 21
  • 122
  • 183
LUNA
  • 11
  • 4

2 Answers2

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.

Community
  • 1
  • 1
Manwal
  • 23,450
  • 12
  • 63
  • 93
  • 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