Android Open Source - TextSpam Messager






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;
//from   w w w  . ja  v a  2s . co m
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.telephony.SmsManager;

import java.util.ArrayList;

/**
 * Created by andrew on 19/08/13.
 */
public class Messager {
    SmsManager sm;
    PendingIntent intent;
    int failedMessages = 0;
    Context context;

    public Messager(Context context) {
        this.context = context;
        sm = SmsManager.getDefault();
        intent = PendingIntent.getBroadcast(context, 0,
                new Intent("SMS_SENT"), 0);
    }

    public synchronized void sendMessage(String address, String message) {
        message = (message.equals("")) ? " " : message;
        sm.sendTextMessage(address, null, message, intent, null);
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }

    public synchronized void sendMessageToContact(String address, String message, int number) {
        for (int i = 0; i < number; i++) {
            sendMessage(address, message);
            //Toast.makeText(context, "Sending Text " + (i + 1) + " of " + number + " to " + address,Toast.LENGTH_SHORT).show();

        }
    }

    public synchronized void sendMessagesToAll(ArrayList<Custom> item, int number, String message) {
        for (int i = 0; i < item.size(); i++) {
            sendMessageToContact(item.get(i).getPhoneNumber().toString(), message, number);
        }
    }


}

//tast to run in background and send messages
class SendMessagesTask extends AsyncTask<Void, Void, Void> {
    ArrayList<Custom> item;
    int frequency;
    String message;
    Messager messager;
    Context context;

    protected SendMessagesTask(ArrayList<Custom> item, int frequency, String message, Context context) {
        this.item = item;
        this.frequency = frequency;
        this.message = message;
        this.context = context;
        messager = new Messager(context);
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected Void doInBackground(Void... voids) {

        messager.sendMessagesToAll(item, frequency, message);
        return null;
    }


}




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