Activity not waiting for result
<p>I have an activity called CForm. I would like to call CGForm for result. After i get the result start another activity. The problem is that when i start the details_click method , it executes the CGFORM, but doesn't waits for setting the result in the form, it jumps to the CDFORM.</p>

<p>here is the code for CFORM:</p>

<pre><code>////////////////////////////CForm/////////////////////////
  public boolean details_click()
      {
          if(listview.getCheckedItemPosition()&gt;=0)
            {   
               ArrayList&lt;ComandaClass&gt; listcompos = CClass.C();

                int gestiuneId = 0;
                if ((configurare.bAlCom) &amp;&amp; (listcompos.size() == 0))
                {
                    StocClass.setComandaContextForDB(this);
                    listGest = StocClass.Gestiuni_Get();
                    if (listGest.size() &gt; 1)
                    {
                          Intent intent = new Intent();
                        intent.setClass(CForm.this,CGForm.class);
                        startActivityForResult(intent,GET_CODE);//here i would like to get back the result from CGForm

                        dGeid=getGIdResult;
                    }
                }

                boolean tof = true;
                if ((configurare.bGCom) &amp;&amp; (gestiuneId == -1))
                    tof = false;
                if (tof)
                {
                       dCid=listCom.get(listview.getCheckedItemPosition()).getCId();
                     dClid=listCom.get(listview.getCheckedItemPosition()).getClId();
                     dF=listCom.get(listview.getCheckedItemPosition()).getF();

                        Intent intent = new Intent();
                    intent.setClass(CForm.this,CDForm.class);
                    startActivity(intent);
                }
                return true;
            }
          else
          {
              Toast.makeText(this, "X", 5000).show();
              return false;
          }

      }

       public static int getGIdResult=-1;
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) 
      {


           if (requestCode == GET_CODE)
           {
                if (resultCode == RESULT_OK) 
                {
                    getGIdResult=data.getIntExtra("GIdResult",-1);
                }
                else
                {
                    getGIdResult=-1;
                }
           } 
           super.onActivityResult(requestCode, resultCode, data);
      }
</code></pre>

<p>CGFORM code:</p>

<pre><code>  ////////////////////CGForm//////////////////
      public class CGForm extends Activity 
{
     public static ArrayList&lt;StocClass&gt; listG=null;
     public static int gid;
     ListView listview=null;
     Button btnOK=null;

     @Override
     public void onCreate(Bundle savedInstanceState) 
     {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.comenzigestiuni);

        Locale locale = new Locale("en");   
        Locale.setDefault(locale);  
        Configuration config = new Configuration();  
        config.locale = locale;  
        getBaseContext().getResources().updateConfiguration(config,getBaseContext().getResources().getDisplayMetrics());

        listview=(ListView)findViewById(R.id.listViewDG);

        listG = CForm.listGest;

        CG_Load();
     }//oncreate
     private void CG_Load()
     {
     //..adding data to listview
          btnOK=(Button)findViewById(R.id.menuItemOk);
          btnOK.setOnClickListener(new OnClickListener() 
          {
            public void onClick(View v) 
            {
                 if (listview.getCheckedItemPosition() &gt;= 0)
                 {
                     gestiuneid = listG.get(listview.getCheckedItemPosition()).getGId();

                     Intent intent = new Intent();
                     intent.putExtra("GIdResult", gestiuneid);
                     setResult(RESULT_OK, intent);

                     finish();
                 }
            }
          });
     }//CG_Load

     @Override
    protected void onStop() 
     {
         gestiuneid=-1;

         Intent intent = new Intent();
         intent.putExtra("GIdResult", gestiuneid);
         setResult(RESULT_OK, intent);

         super.onStop();
     }

}
</code></pre>

<p>thanks advanced !</p>
