Android Open Source - tinysmsgate S M S Receiver






From Project

Back to project page tinysmsgate.

License

The source code is released under:

GNU General Public License

If you think the Android project tinysmsgate 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 rocks.jahn.tinysmsgate;
/*from ww w .  j a  v a 2s .  c o  m*/
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.telephony.SmsMessage;

public class SMSReceiver extends BroadcastReceiver {
  public SMSReceiver() {
    super();
  }

  @Override
  public void onReceive(Context context, Intent intent) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    boolean forwardingEnabled = preferences.getBoolean("chkForwardSMS", false);
    
    if(forwardingEnabled) {
      Bundle bundle = intent.getExtras();
      SmsMessage[] messages = null;
      String from = "";
      String message = "";
      
      if(bundle != null) {
        Object[] pdus = (Object[]) bundle.get("pdus");
        
        messages = new SmsMessage[pdus.length];
        for(int i = 0; i < messages.length; i ++) {
          messages[i]= SmsMessage.createFromPdu((byte[]) pdus[i]);
          message += messages[i].getMessageBody().toString();
          from = messages[i].getOriginatingAddress();
        }
      }
      
      new SMSForwarder(
        context,
        from,
        message,
        preferences.getString("txtUrl", ""),
        preferences.getString("lstSendMethod", "POST")
      ).execute();
    }
  }
  
}




Java Source Code List

fi.iki.elonen.NanoHTTPD.java
rocks.jahn.tinysmsgate.Preferences.java
rocks.jahn.tinysmsgate.SMSForwarder.java
rocks.jahn.tinysmsgate.SMSGateService.java
rocks.jahn.tinysmsgate.SMSGateWebServer.java
rocks.jahn.tinysmsgate.SMSReceiver.java
rocks.jahn.tinysmsgate.TinySMSGate.java
rocks.jahn.tinysmsgate.Utils.java