title: Android call onactivityresult from onitemclick
body: <p>I need to pass the value using intent from onItemClick method from 1.java to onActivityResult in 2.Java</p>
  
  <p>1.java</p>
  
  <pre><code>public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,long id) 
  {     
  
      int songindex=position; 
      Intent intent2 = new Intent(this, Play.class);
      intent2.putExtra("songindex",songindex);
      setResult(100, intent2);
      startActivity(intent2);
  
  
  }
  </code></pre>
  
  <p>2.java</p>
  
  <pre><code>public class Play extends Activity {
  MediaPlayer mp;
  int currentsong=0;  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.play);
      currentsong=getIntent().getIntExtra("songindex",-1);
  
  }
  
  
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode,
              Intent data) {
          // TODO Auto-generated method stub
          super.onActivityResult(requestCode, resultCode, data);
          if(resultCode==100)
          {
              //Intent intent1=getIntent();
              //currentsong=getIntent().getExtras().getInt("songindex");
              pl(currentsong);
          }
      }
  </code></pre>
  
  <p>my problem is intent value not passed from 1.java to 2.java and when onItemClick is clicked i need to pass the value using intent and call the method pl(songindex)</p>