3

I'm developing an application for school teachers. I want it to send SMS to all the parents. So I want to send SMS to non-Android devices also (i.e. Android application to any other device which may not have Internet also).

If possible, please give me the solution. This is what I have so far:

public class SendSMSActivity extends Activity {
    Button buttonSend;
    EditText textPhoneNo;
    EditText textSMS;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        buttonSend = (Button) findViewById(R.id.buttonSend);
        textPhoneNo = (EditText) findViewById(R.id.editTextPhoneNo);
        textSMS = (EditText) findViewById(R.id.editTextSMS);
        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();
//              }
        String number = "9940571282";
        String message = "hi there";
        Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "sms:" + number ) ); 
        intent.putExtra( "sms_body", message ); 
        startActivity( intent );
            }
        });
    }
}
Nic
  • 12,220
  • 20
  • 77
  • 105
Maheswaran
  • 107
  • 9

8 Answers8

0

SMS is not related to any specific platform.

So, "YES", you can send SMS to non-android phones.

Sending SMS also doesn't need the phone to be connected to internet.

So, "YES", you can send SMS to a device which may not have internet.

As for a solution, please do a bit of research first, and try out a few samples and examples.

Kumar Bibek
  • 9,016
  • 2
  • 39
  • 68
0

SMS are not OS/Device dependent.

You can send sms in android using this code.

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

Also add this permission in the manifest file-

<uses-permission android:name="android.permission.SEND_SMS" />
nikvs
  • 1,090
  • 5
  • 9
0

Why not, sending Sms doesn't require Internet permission and we send sms to Phone number, yes it is possible

SmsManager smsMgr = SmsManager.getDefault();
smsMgr.sendTextMessage(phoneNumber, null, messageBody,null,null);

use permission

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

Hope this works

Amit
  • 391
  • 3
  • 15
  • Use WRITE_SMS permission – Amit Dec 24 '13 at 07:55
  • Use WRITE_SMS permission SmsManager is the only way to send sms to any phone number(if you are not using any sms gateway) – Amit Dec 24 '13 at 07:56
  • It's working, I want to send free sms to multiple number's from my android application with some common name don't from my number, for example "Vidhayala Hr.Sec.School" instead of my number. – Maheswaran Dec 24 '13 at 10:01
  • you should use some sms gateway, and for that you will require INTERNET permission google it you will find out sms gateway, you want something similar to way2sms which send msg but every receiver see sender name as Way2Sms, am i right ? if yes then you will need sms gateway – Amit Dec 24 '13 at 12:46
0

Yes you can send SMS to any non Android device: Use this code to send sms to any number:

SmsManager.getDefault().sendTextMessage("Phone Number", null, "Message", null, null);
AabidMulani
  • 2,325
  • 1
  • 28
  • 47
  • It's not working, I am used this code already, I am having Nokia 101 mobile,just now send the message from my Android Emulator to my number, but I didn't get any message. – Maheswaran Dec 24 '13 at 07:04
  • How can emulator send SMS..? Please run the apk on an Android device. It should work, also dont forget to add this permission in your manifest – AabidMulani Dec 24 '13 at 07:29
  • Is it must,the Android device have Internet to send SMS? – Maheswaran Dec 24 '13 at 08:54
  • Hey, Internet is NOT REQUIRED TO SEND SMS. IT JUST NEED A SIM CARD AND SUFFICIENT BALANCE TO SEND IT. Use the above code in your app and run it on the Android device which has a sim card. Please do that and it will run! – AabidMulani Dec 24 '13 at 09:13
  • Thanks Mulani, it's work now, I need to send free SMS,need not from my Number, and how to send SMS to multiple number's? I give the number's separated with commas,but it's not work. Also the message send from my number with Common name for example "Vidhyalaya Hr.Sec.Schoo" like this. – Maheswaran Dec 24 '13 at 09:45
  • When i had to send SMS to multiple recipients i used a for loop with the above line. No other easier way available. So store your numbers in an Array of string and fire this intent in a for loop. – AabidMulani Dec 24 '13 at 11:40
0

Once SMS is sent from device... it doesn't matter from which the SMS is sent and which device it is going to be sent.

To know how to develop SMS application... just google it (android sms example project)

Following are few links:

  1. Link1
  2. Link2
Tabrej Khan
  • 894
  • 6
  • 15
0

Yes, here are your possibilities:

  1. Send SMS via an Intent (Open the Messaging application from within your app), see separate thread re this
  2. Send SMS directly from your app using the SmsManager class, see separate thread re this
  3. Use an external service to send your message, like Twilio for example.
Community
  • 1
  • 1
Tom Susel
  • 3,397
  • 1
  • 24
  • 25
0

yes You can use the following code:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + phoneNumber)));
Dev 9
  • 263
  • 2
  • 5
  • ok..Also add this permission in the manifest file- – Dev 9 Dec 24 '13 at 09:54
  • It's working, I want to send free sms to multiple number's from my android application with some common name don't from my number, for example "Vidhayala Hr.Sec.School" instead of my number. – Maheswaran Dec 24 '13 at 10:00
  • ok.. you can use any api(service). like way2sms, fullonsms etc. – Dev 9 Dec 24 '13 at 12:05
0

use that code

try {

                     Intent sendIntent = new Intent(Intent.ACTION_VIEW);
                     sendIntent.putExtra("sms_body", "Check out My Photos on Virtual Ramp Walk on Your Android.Download the free app or visit Virtual Ramp Walk"); 
                     sendIntent.setType("vnd.android-dir/mms-sms");
                     startActivity(sendIntent);

                } catch (Exception e) {
                    Toast.makeText(getApplicationContext(),
                        "SMS faild, please try again later!",
                        Toast.LENGTH_LONG).show();
                    e.printStackTrace();
                }
The Ray of Hope
  • 738
  • 1
  • 6
  • 16