My wild guess is you are clicking on the button more than once... put the send() inside a if loop and set the boolean to false after calling send()
Nithin On May 10, 10:53 am, mike <hasitharand...@gmail.com> wrote: > hi guys, > > i have a application which send sms. but i found that the application > always sends 2 sms messages to the selected number. > > couldn't figure out how is this happening. so i'll paste the code > below if you have any suggestions just let me know > > public class Compose extends Activity { > private EditText name, msg; > private Button send; > private Spinner spinnerTimer; > private ImageButton contacts; > String contactName, number; > private ImageView shp; > private HashMap<String, Integer> color; > > �...@override > protected void onCreate(Bundle savedInstanceState) { > // TODO Auto-generated method stub > super.onCreate(savedInstanceState); > setContentView(R.layout.compose_sms); > colorMap(); > name = (EditText) findViewById(R.id.num); > msg = (EditText) findViewById(R.id.msg); > send = (Button) findViewById(R.id.snd); > send.setOnClickListener(new OnClickListener() { > > �...@override > public void onClick(View v) { > // TODO Auto-generated method stub > Log.d("Button", "Button"); > send("454546", "Mike"); > return; > } > }); > > } > > public void alert(String header, String body) { > new AlertDialog.Builder(this).setTitle(header).setMessage(body) > .setCancelable(true).setNeutralButton("Close", > new DialogInterface.OnClickListener() { > �...@override > public void onClick(DialogInterface dialog, > int which) { > // TODO Auto-generated method stub > } > }).show(); > } > > �...@override > public boolean onKeyDown(int keyCode, KeyEvent event) { > // TODO Auto-generated method stub > if (keyCode == KeyEvent.KEYCODE_BACK) { > finish(); > Intent intent = new Intent(this, Menu.class); > startActivityForResult(intent, 107); > return true; > } > return false; > } > > private void send(String number,String msg) { > > PendingIntent pi = PendingIntent.getActivity(this, 0, > new Intent(this, Compose.class), 0); > Log.d("SMS", "SMS"); > SmsManager sms = SmsManager.getDefault(); > sms.sendTextMessage(number, null, msg, pi, > null); > > } > > } > > regards, > Mike > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group > athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en