Android Open Source - smsgcm-client Sms Sender






From Project

Back to project page smsgcm-client.

License

The source code is released under:

Apache License

If you think the Android project smsgcm-client listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.omgren.apps.smsgcm.client;
/*from  w ww  .  ja v a  2s  .c om*/
import static com.omgren.apps.smsgcm.client.CommonUtilities.displayMessage;

import java.util.ArrayList;

import android.content.ContentValues;
import android.content.Context;
import android.net.Uri;
import android.telephony.SmsManager;
import android.util.Log;

public class SmsSender {
  private static final String TAG = "SmsSender";
  public void send(Context context, String recipient, String message){
    SmsManager smsman = SmsManager.getDefault();
    ArrayList<String> msgs = smsman.divideMessage(message);
    smsman.sendMultipartTextMessage(recipient, null, msgs, null, null);

    record_sent(context, recipient, message);
    Log.i(TAG, "sent sms to " + recipient + " saying " + message);
    displayMessage(context, context.getString(R.string.sent_sms, recipient, message));
  }

  public void record_sent(Context context, String address, String message){
    // store the sent sms in the sent folder (that shouldn't be necessary?!)
    ContentValues values = new ContentValues();
    values.put("address", address);
    values.put("body", message);
    context.getContentResolver().insert(Uri.parse("content://sms/sent"), values);
  }

}




Java Source Code List

com.omgren.apps.smsgcm.client.CertException.java
com.omgren.apps.smsgcm.client.CertUtilities.java
com.omgren.apps.smsgcm.client.CommonUtilities.java
com.omgren.apps.smsgcm.client.GCMIntentService.java
com.omgren.apps.smsgcm.client.HttpUtilities.java
com.omgren.apps.smsgcm.client.MainActivity.java
com.omgren.apps.smsgcm.client.ServerUtilities.java
com.omgren.apps.smsgcm.client.SettingsActivity.java
com.omgren.apps.smsgcm.client.SmsReceiver.java
com.omgren.apps.smsgcm.client.SmsSender.java
com.omgren.apps.smsgcm.common.SmsMessageDummy.java