Showing posts with label send sms. Show all posts
Showing posts with label send sms. Show all posts

Friday, December 20, 2013

Android: How to send SMS


Add Permission into Manifest

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



Add API into Source
private void sendSMS(String m_phoneNumber, final String m_smsMessage)
{      
    String SENT         = "SMS_SENT";
    String DELIVERED = "SMS_DELIVERED";
     
    Log.d(TAG, "In sendSMS()");

    PendingIntent sentPI    
                             = PendingIntent.getBroadcast(this, 0, new Intent(SENT),      0);
    PendingIntent deliveredPI
                             = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);
             
    Log.d(TAG, "sendTextMessage() : number = " + m_phoneNumber
                                                                     + ", Message = " + m_smsMessage);
     
    // Write SMS data into DB
    ContentValues values = new ContentValues();
    values.put("address",   m_phoneNumber.replace("-", ""));
    values.put("body",       m_smsMessage);
    values.put("protocol",  MESSAGE_TYPE_SENT);
    getContentResolver().insert(Uri.parse("content://sms/sent"), values);
     
    // Send Text Message
    SmsManager.getDefault().sendTextMessage(m_phoneNumber.replace("-", ""),
                                                               null, m_smsMessage, sentPI, deliveredPI);
}

Android: Group SMS which is based on contact group

This post is just for introduce "Group SMS" application.
Sometimes, we need to send SMS to my customer, friends or anyone.
In this case, this application can help you to send SMS to people.

  

  

We can input prefix and postfix about each contact name and message body.
For example,
   Prefix               : Dear
   Contact Name  : Victor, Crum
   Postfix             : .
   Message Body : Thanks for your APP.

   Then 2 messages will be made automatically as below.
   - Dear Victor.
      Thanks for your APP.
   - Dear Crum.
      Thanks for your APP.

   Finally, this messages will be sent to each person.


You can download this APP for nothing as the below path.
App Download