title: How to close this activity?
body: <p>I created my lockscreen application that trigerred by a SMS.. i have ListenSMS class that always listen for incoming SMS. Here's the code :</p>
  
  <pre><code>for (SmsMessage message : messages) {
      String tempMessage[] = message.getDisplayMessageBody().toString().split(" ");
  
      //checking command dan password                             
      if (tempMessage[0].toString().equalsIgnoreCase("andro-lock") &amp;&amp; tempMessage[1].toString().equals(tempPassword.toString())) {
          //Toast.makeText(ListenSMSservice.this, "Menjalankan command andro-lock", Toast.LENGTH_LONG).show();
          openDatabase();
          updateStatusL();
          Intent myIntent = new Intent(ListenSMSservice.this,LockScreenForm.class);
          myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          getApplication().startActivity(myIntent);
      }
      else if (tempMessage[0].toString().equalsIgnoreCase("andro-unlock") &amp;&amp; tempMessage[1].toString().equals(tempPassword.toString())) {
          //Toast.makeText(ListenSMSservice.this, "Menjalankan command andro-unlock", Toast.LENGTH_LONG).show();
          openDatabase();
          updateStatusNL();                                                                   
          Intent myIntent = new Intent(ListenSMSservice.this,LockScreenForm.class);
          myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          Bundle myKillerBundle = new Bundle();
          myKillerBundle.putString("kill","1");
          myIntent.putExtras(myKillerBundle);
          getApplication().startActivity(myIntent);
      }
  }
  </code></pre>
  
  <p>If ListenSMS service has received an <code>andro-lock</code> command, it will go to the <code>lockscreen.java</code>  and will go to the lockscreen.java with intent extra (putExtra) <code>kill</code> when it receive command <code>andro-unclock</code>. <strong>Here's my lockscreen.java:</strong></p>
  
  <pre><code>public class LockScreenForm extends Activity implements OnClickListener {
      /** Called when the activity is first created. */
  
      @Override
      public void onCreate(Bundle bundle) {
          super.onCreate(bundle);
          setContentView(R.layout.lockscreen);             
  
          Bundle extra = getIntent().getExtras();
          if (extra == null) {
              return;
          }
          //Toast.makeText(this, extra.getString("kill"), 1).show();
          else if(this.getIntent().getExtras().getString("kill").equalsIgnoreCase("1")) {
              try {
                  Toast.makeText(this, "extra accepted", 1).show();
                  finish();
              } catch (Exception e) {
                  // TODO: handle exception
                  Toast.makeText(this, e.getMessage(), 1).show();
              }
  
          }
  
      }
  }
  </code></pre>
  
  <p>I want to close my locksreen.java when my <code>ListenSMS</code> service has received "andro-unlock" command, so I put extra on intent "kill" and check it in lockscreen.java. This lockscreen.java can check the extra intent and can display a toast "extra accepted" but can close the lockscreen activity with finish().</p>
  
  <p>My assumption is for now that <code>Intent.FLAG_ACTIVITY_NEW_TASK</code> is duplicating a locksreen activity. So it will create a double lockscreen activity and the finish method is closing another lockscreen.java that started by <code>Intent.FLAG_ACTIVITY_NEW_TASK</code>. That's only assumption. Am i wrong? Please correct me.</p>
  
  <p>Has anyone know how to solve my problem? I really want that "andro-unlock" command can close the lockscreen activity and need it works for my college final project. Please help.</p>