title: android: Kill and Activity onClick
body: <p>In my android app i am launching an activity using Intent. this activity uses a different layout which has a close ImageButton. I want to set the onClick event to close this activity and go back to the previous activity. i am using the finish() method to achieve this but nothing happens when i click on the close Image Button.</p>
  
  <p>Following is the Code i am using:</p>
  
  <p>To Launch the Activity:</p>
  
  <pre><code>public void stOn(){
      Button sb = (Button)findViewById(R.id.sb);
      sb.setOnClickListener(new OnClickListener(){
          @Override
          public void onClick(View v){
              Intent scIntent = new Intent(MainActivity.this, St.class);
              MainActivity.this.startActivity(scIntent);
          }
      });
  } 
  </code></pre>
  
  <p>And to Destroy the Activity:</p>
  
  <pre><code>public void stOff(){
      ImageButton pw = (ImageButton)findViewById(R.id.pw);
      pw.setOnClickListener(new OnClickListener(){
          @Override
          public void onClick(View v){
              finish(); // Finish Current Activity
          }
      });
  }
  </code></pre>
  
  <p>What am i doing wrong ?</p>