title: Android all variables are reset when SMS is sent
body: <p>Hey I'm making an app in which I need to send a text message but every time I send the message the app opens again and all the variables are reset(I have tried to implement a system that save the variables but they still get reset), however it still sends the message. Why is it doing this, and how can I fix it; this is my code</p>
  
  <pre><code>public void sendSMS(String phono, String mes)
      {
          PendingIntent pi = PendingIntent.getActivity(this, 0,
          new Intent(this, MainActivity.class), 0);
          SmsManager sm = SmsManager.getDefault();
          sm.sendTextMessage(phono, null, mes, pi, null);
      }
           //Button that uses method
    b = (Button) findViewById(R.id.b);
      b.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v)
          {
              phono = "personal phone number";
              if (phono.length() &gt; 0 &amp;&amp; mes.length() &gt; 0)
                  sendSMS(phono, mes);
              }
          });
  </code></pre>