title: Android wait for another activity result - it didn't work
body: <p>How to wait to another activity result in android. 
  I have written the following code but after the activity finishes, it always goes to onCreate() method.</p>
  
  <p><strong>I have tab activity.From one tab activity , i called another activity, that is popup window......After finished popup window It should go back to previous activity</strong></p>
  
  <pre><code>   @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
      super.onListItemClick(l, v, position, id);
      Object o = this.getListAdapter().getItem(position);
      keyword = o.toString();
      positions = position;
  
      if(position != 0 ){
          Bundle bundle = new Bundle();
  
          Intent showContent = new Intent(getApplicationContext(),SalesRouteDevitionActivity.class);
          int postion = position;
          String aString = Integer.toString(postion);
          bundle.putString("positon", aString);
          showContent.putExtras(bundle);
          startActivityForResult(showContent,0);
      }else{
  
          Intent intent = new Intent(SalesRouteActivity.this, ListRetailerActivity.class);
          Bundle bundle = new Bundle();
          bundle.putString("RouteName", keyword);
          intent.putExtras(bundle);
          View view = SalesActivityGroup.group.getLocalActivityManager().startActivity("", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();  
          SalesActivityGroup.group.replaceView(view);
      }
  }
  
  
     @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
  
         Log.w("onActivityResult" ," --requestCode ---" + requestCode + " -- resultCode -- " + resultCode + " -- data --" + data);
        if(resultCode==0){
            Toast.makeText(this, "Reason has been successfully.", Toast.LENGTH_LONG).show();
            if(resultCode==RESULT_OK)
                Toast.makeText(this, "Reason has been successfully.", Toast.LENGTH_LONG).show();
           else
                Toast.makeText(this, "Fail", Toast.LENGTH_LONG).show();
        }
    }
  </code></pre>
  
  <p>and SalesRouteDevitionActivity.class</p>
  
  <pre><code>    public class SalesRouteDevitionActivity extends Activity {
  private String array_spinner[];
  String param1 = "";
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.route_diviation_popup);
      array_spinner=new String[2];
      array_spinner[0]="Rain";
      array_spinner[1]="Floods";
  
      Spinner s = (Spinner) findViewById(R.id.spinner1);
      ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, array_spinner);
      s.setAdapter(adapter);
      Button button = (Button) findViewById(R.id.submit);
  
       button.setOnClickListener(new OnClickListener() {
           public void onClick(View v) {
  
  
               Intent mIntent = new Intent();
               setResult(RESULT_OK);
               finish();
  
  
  
           }
       });
  
  }
  
  }
  </code></pre>
  
  <p>This is my Tab Activity.I am using ActivityGroup </p>
  
  <pre><code>  public class MainActivity extends TabActivity {
  int selectedTab;
  TabHost tabHost ;
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.tabview);
  
      TabHost t = getTabHost();
      tabHost = (TabHost)findViewById(android.R.id.tabhost);
  
      TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
      TabSpec secondTabSpec = tabHost.newTabSpec("tid1");
      TabSpec thirdTabSpec = tabHost.newTabSpec("tid1");
      /** TabSpec setIndicator() is used to set name for the tab. */
      /** TabSpec setContent() is used to set content for a particular tab. */
      firstTabSpec.setIndicator("Sales").setContent(new Intent(this,SalesActivityGroup.class));
      secondTabSpec.setIndicator("Admin").setContent(new Intent(this,SettingActivityGroup.class));
      thirdTabSpec.setIndicator("Setting").setContent(new Intent(this,SettingActivityGroup.class));
  
  
      tabHost.addTab(firstTabSpec);
      tabHost.addTab(secondTabSpec);
      tabHost.addTab(thirdTabSpec);
      tabHost.setCurrentTab(0);
      tabHost.setMinimumHeight(25);
  }
  
  public void onTabChanged(String arg0) {
          selectedTab = tabHost.getCurrentTab();
  
  }
  </code></pre>
  
  <p>This is SalesActivityGroup.java</p>
  
  <pre><code> public class SalesActivityGroup extends ActivityGroup {
  
  public static SalesActivityGroup group;
  private ArrayList&lt;View&gt; history;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      this.history = new ArrayList&lt;View&gt;();
      group = this;
  
      View view = getLocalActivityManager().startActivity("Sales",
              new Intent(this, SalesRouteActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
              .getDecorView();
  
      replaceView(view);
  
  }
  
  public void replaceView(View v) {
      history.add(v);
      setContentView(v);
  
  }
  
  public void back() {
      if (history.size() &gt; 0) {
          history.remove(history.size() - 1);
          if (history.size() &gt; 0) {
              setContentView(history.get(history.size() - 1));
          } else {
              finish();
          }
      } else {
          finish();
      }
  }
  
  @Override
  public void onBackPressed() {
      SalesActivityGroup.group.back();
      return;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I know this is the way we should do, but really i dont know why its not working my part....</p>
  
  <p>I didn't go to onActivityResult() method &amp; it didnt print <code>Log</code>  also</p>
  
  <p>Please help me..</p>
  
  <p>Thanks in advance</p>