passing image from galery activity to main activity(canvas)
<p>i have a button on MainActivity that when i click it it open activity that show galery photo</p>

<p>and when i clicked one of the photo list , i want to get path of this picture to MainActivity</p>

<p>this is my code </p>

<p>MainActivity</p>

<pre><code>case R.id.btn_tool_galery:
    enter Intent in=new Intent(this,ListViewImagesActivity.class);
    startActivityForResult(in, 2);  
    break;

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {

    case 2:
        if (resultCode == Activity.RESULT_OK) {
            Bundle extras = getIntent().getExtras(); 
            int position = extras.getInt("id");
            // and get whatever type user account id is

            // Selected image id
            //int position = this.getIntent().getExtras().getInt("id");
            Toast.makeText(TpMainActivity.this, "position  "+position, Toast.LENGTH_LONG).show();
        }
    }
}
</code></pre>

<p>this is my galeryAcivity </p>

<pre><code>public void onItemClick(AdapterView&lt;?&gt; a, View v, int position, long id) { 

    // Sending image id to PictureActivity
    Intent i = new Intent();
    // passing array index
    i.putExtra("id", position);
    setResult(Activity.RESULT_OK, i);
    finish();
</code></pre>

<p>but when i run it i have  error at this stade </p>

<pre><code>     int position = extras.getInt("id"); 
</code></pre>
