title: android how to kill an activity in another one?
body: <p>In an app,there are 3 activities,A,B,C. A is to log in .B is the menu,C is to set values. The working line: A->B->C. In C, there is a button named logout. When clicking logout , I setResult to B ,finish C and start A. In B,I override onActivityResult, when the resultcode is right, I finish B. But the testing data shows when A is restarted by C,B isn't be finished. Solutions are welcomed! Here is the code:</p>
  
  <pre><code>    Activity A: LoginActivity.java
      @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);      
      setContentView(R.layout.login);
              login=(Button) findViewById(R.id.login);
              login.setOnClickListener(new OnClickListener() {          
          @Override
          public void onClick(View v) {
                       Intent intent=new Intent(LoginActivity.this,MenuActivity.class);
              startActivity(intent);
              LoginActivity.this.finish();
                      }
             }
      }
  
     Activity B: MenuActivity.java
  
      @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);      
      setContentView(R.layout.login);
              setting=(Button) findViewById(R.id.login);
              setting.setOnClickListener(new OnClickListener() {        
          @Override
          public void onClick(View v) {
                       Intent settingintent=new Intent(MenuActivity.this, SettingActivity.class);
              startActivityForResult(settingintent,1);
                      }
             }
      }
  
      @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  
      if(requestCode==1){
          switch(resultCode){
              case RESULT_CANCLED:
                  break;
              case RESULT_OK:
                  MenuActivity.this.finish();
                  Log.i(TAG, "I'm killed"+System.currentTimeMillis());
                  break;
          }
      }   
  }
      Activity C: Setting.java
      @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);      
      setContentView(R.layout.login);
              logout=(Button) findViewById(R.id.login);
              logout.setOnClickListener(new OnClickListener() {         
          @Override
          public void onClick(View v) {
                       Intent mIntent=new Intent(SettingActivity.this,LoginActivity.class);
           startActivity(mIntent);
           SettingActivity.this.setResult(RESULT_OK);
           SettingActivity.this.finish();
  
                      }
             }
      }
  </code></pre>