• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Automatic Forwarding MMS in Android

ashajf

Lurker
Hi All!
I am new to android and i wanted an app to automatically forward the incoming MMS to a selected number from the db. I have heard that dealing with MMS is quit difficult in android than SMS. I done some googling but could not find a working code.

I have gone blank since I am really new to Android. Can somebody please help me??
Thanks in advance!!
 
Not going to give a full working example. But going to show you how you'd do this.

You will create a BroadcastReceiver class, register to to receive broadcasts for android.provider.Telephony.SMS_RECEIVED notification in your manifest like this:

Code:
 <receiver android:name=".MyReceiver"> 
            <intent-filter> 
                <action android:name=
                    "android.provider.Telephony.SMS_RECEIVED" /> 
            </intent-filter> 
        </receiver>

Then in your onReceive method of your receiver, send out an sms to the number you want. Like this

Code:
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();
    Object[] pdus = (Object[]) bundle.get("pdus");
    String message = SmsMessage.createFromPdu((byte[])pdus[0])
    PendingIntent pi = PendingIntent.getActivity(this, 0,
            new Intent(this, SMS.class), 0);                
    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phoneNumber, null, message, pi, null);
}

And dont forget to add the following permissions to your manifest as well

Code:
<uses-permission android:name="android.permission.SEND_SMS">
    </uses-permission>
    <uses-permission android:name="android.permission.RECEIVE_SMS">
    </uses-permission>
 
Back
Top Bottom