Unwanted automated creation of new instances of an activity class

Posted by Marko on Stack Overflow See other posts from Stack Overflow or by Marko
Published on 2010-05-11T21:08:06Z Indexed on 2010/05/12 0:04 UTC
Read the original article Hit count: 209

Filed under:
|

I have an activity (called Sender) with the most basic UI, only a button that sends a message when clicked. In the onClickListener I only call this method:

private void sendSMS(String msg)
    {
     PendingIntent pi = PendingIntent.getActivity(this, 0, 
      new Intent(this, Sender.class), 0);
     PendingIntent pi = PendingIntent.getActivity(this, 0, myIntent, 0);
     SmsManager sms = SmsManager.getDefault();
     sms.sendTextMessage("1477", null, msg, pi, null);
    }

This works ok, the message is sent but every time a message is sent a new instance of Sender is started on top of the other. If I call sendSMS method three times, three new instances are started. I'm quite new to android so I need some help with this, I only want the same Sender to be on all the time

© Stack Overflow or respective owner

Related posts about android

Related posts about java