Android Open Source - TextSpam Message Reciever






From Project

Back to project page TextSpam.

License

The source code is released under:

Apache License

If you think the Android project TextSpam 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.andrew749.textspam;
/*w  ww.j  av  a2 s . c om*/
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;

import java.util.ArrayList;

public class MessageReciever extends BroadcastReceiver {
    /**
     * action is .sendmessages
     *
     * @param context
     * @param intent
     */
    Object[] messages;

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getStringExtra("resend") != null) {
            //if the message is one being resent
            ArrayList<Custom> item = new ArrayList<Custom>();
            Log.d("Error", "some messages error .... resending");
            try {
                messages = (Object[]) intent.getBundleExtra("unsent").get("pdus");
                SmsMessage[] sms = new SmsMessage[messages.length];
                //iterate over all the messages that were unsent
                for (int i = 0; i < messages.length; i++) {
                    sms[i] = SmsMessage.createFromPdu((byte[]) messages[i]);
                    Log.d("Error recipient ", "" + sms[i].getOriginatingAddress());
                    item.add(new Custom(sms[i].getOriginatingAddress()));
                    new SendMessagesTask(item, 1, sms[i].getMessageBody(), context);
                    //clear the array as to not waste memory
                    item.clear();
                }
            } catch (NullPointerException e) {
                e.printStackTrace();
            }

        } else {
            //if the message isnt being resent
            int frequency;
            ArrayList<Custom> item;
            String message;
            Bundle information = intent.getExtras().getBundle("information");
            frequency = information.getInt("freq");
            message = information.getString("message");
            item = (ArrayList<Custom>) information.getSerializable("contact");
            Log.d("Success", "got items");
            new SendMessagesTask(item, frequency, message, context).execute();

        }
    }
}




Java Source Code List

com.andrew749.textspam.Custom.java
com.andrew749.textspam.MainActivity.java
com.andrew749.textspam.MessageReciever.java
com.andrew749.textspam.Messager.java
com.andrew749.textspam.SwipeDismissListViewTouchListener.java
com.andrew749.textspam.Adapters.AutoCompleteCursorAdapter.java
com.andrew749.textspam.Adapters.ContactListAdapter.java
com.andrew749.textspam.Database.ConversationModel.java
com.andrew749.textspam.Database.DataSource.java
com.andrew749.textspam.Database.DatabaseHelper.java
com.andrew749.textspam.Fragments.Conversations.java
com.andrew749.textspam.Fragments.QuickMessageFragment.java
com.andrew749.textspam.Fragments.TutorialActivity.java
com.inscription.ChangeLogDialog.java
com.inscription.WhatsNewDialog.java