Sending Outgoing SMS, and Reporting Confirmations

Put your problem here if it does not fit any of the other categories.

Sending Outgoing SMS, and Reporting Confirmations

Postby hwrdprkns » Wed Nov 25, 2009 9:06 pm

Hi guys, I'm trying to write a program to send multiple messages to the same person. I think I have most of the stuff I need I just have a couple questions.

1. I don't think my call to send sms in the SmsManager.sendTextMessage is correct, does anyone know how to properly call this class/method?

2. I'm sort of new to java and I only know how to do one event handler/listener. How can i create a second. I tried to do this in my code but i'm not sure if i've done it correctly.

Heres my code below.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. /*************************
  3.  
  4.  *
  5.  
  6.  * SMSFlood V1.0
  7.  
  8.  * Author:hwrdprkns/THP Engineering, LLC.
  9.  
  10.  * Date: 11/25/09
  11.  
  12.  *
  13.  
  14.  * This program is designed to send multiple messages to a single recipient. It uses the Android SDK version 5
  15.  
  16.  * and is designed to work with Android 2.0
  17.  
  18.  * ©2009-2010 THP Engineering, LLC.
  19.  
  20.  *
  21.  
  22.  */
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32. package com.hwrdprkns;
  33.  
  34.  
  35.  
  36. import android.app.Activity;
  37.  
  38. import android.os.Bundle;
  39.  
  40. import android.widget.*;
  41.  
  42. import android.telephony.*;
  43.  
  44. import android.view.*;
  45.  
  46. import android.view.View.OnClickListener;
  47.  
  48.  
  49.  
  50. public class SmsFlood extends Activity implements OnClickListener {
  51.  
  52.        
  53.  
  54.         TextView phone_number;
  55.  
  56.         TextView number_messages;
  57.  
  58.         TextView message;
  59.  
  60.         TextView sent_confirmed;
  61.  
  62.         Button Send;
  63.  
  64.         Button Clear;
  65.  
  66.     /** Called when the activity is first created. */
  67.  
  68.     @Override
  69.  
  70.     public void onCreate(Bundle savedInstanceState) {
  71.  
  72.         super.onCreate(savedInstanceState);
  73.  
  74.         setContentView(R.layout.main);
  75.  
  76.        
  77.  
  78.         //get all my vars ready
  79.  
  80.         phone_number = (TextView)this.findViewById(R.id.phone_number);
  81.  
  82.         number_messages = (TextView)this.findViewById(R.id.number_messages);
  83.  
  84.         message = (TextView)this.findViewById(R.id.message);
  85.  
  86.         sent_confirmed = (TextView)this .findViewById(R.id.sent_confirmed);
  87.  
  88.        
  89.  
  90.         Send = (Button)this.findViewById(R.id.send);
  91.  
  92.         Clear = (Button)this.findViewById(R.id.clear);
  93.  
  94.        
  95.  
  96.         //Add event handler here
  97.  
  98.         Send.setOnClickListener((OnClickListener) this);
  99.  
  100.         Clear.setOnClickListener(this.ClearForm());//Seems not to like this call to ClearForm()
  101.  
  102.         }
  103.  
  104.     public void ClearForm(){
  105.  
  106.         phone_number.setText("");
  107.  
  108.         number_messages.setText("");
  109.  
  110.         message.setText("");
  111.  
  112.     }
  113.  
  114.     public void onClick(View v){
  115.  
  116.         sendMessages();
  117.  
  118.     }
  119.  
  120.     protected void sendMessages()
  121.  
  122.     {
  123.  
  124.         int number = Integer.parseInt(number_messages.getText().toString());
  125.  
  126.        
  127.  
  128.         for (int x=0;x<number;x++)
  129.  
  130.         {
  131.  
  132.                 //GETTING ERROR ON THIS LINE BELOW
  133.  
  134.                 SmsManager.sendTextMessage(phone_number.getText().toString(),null,message.toString(),null,null);
  135.  
  136.         }
  137.  
  138.        
  139.  
  140.     }
  141.  
  142. }
  143.  
  144.  
Parsed in 0.039 seconds, using GeSHi 1.0.8.4
hwrdprkns
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Nov 25, 2009 8:14 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests