Passing a Resource to an Activity via an Intent
<p>I have been trying for hours to pass a resource from one Activity to another via an Intent.</p>

<p>Here is the code from my 'Source' Activity:</p>

<pre><code>           Intent myIntent = new Intent(view.getContext(), Activity3.class);

            int res = R.raw.voicefile;

           myIntent = myIntent.putExtra("soundfile", res);

            startActivityForResult(myIntent, 0);
</code></pre>

<p>As you can see, I have a file called voicefile in my raw folder and I am setting res equal to it and passing it with my intent. (I am assuming it is of type int)</p>

<p>In my receiving Activity, I have:</p>

<pre><code>    Intent sender=getIntent();
    int file=sender.getExtras().getInt("soundfile");
</code></pre>

<p>At this point I was HOPING that file would equal R.raw.voicefile in my destination Activity and that I could use my variable 'file' in my MediaPlayer call as such:</p>

<pre><code>          MediaPlayer.create(getBaseContext(), file).start();
</code></pre>

<p>versus:</p>

<pre><code>          MediaPlayer.create(getBaseContext(), R.raw.voicefile).start();
</code></pre>

<p>My problem is whenever I click the button from my Source Activity that launches my Destination Activity, I get a Force Close.</p>

<p>Do you experts see anything glaringly wrong with my code?</p>
