Unwanted automated creation of new instances of an activity class
- by Marko
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