Player getting null after Home button pressed Android
<p>I am creating a streaming player and so far its working fine. I can manage to start and stop the streaming. When I press the home button, the activity is closed but the sound is still playing. I am fine with that, the problem is that when I start the application again and hit the stop button, the object is null. Thats my code:</p>

<pre><code>public class Main extends Activity {

private MediaPlayer player;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

}

public void onPlayClick(View v) {

    try {
        player = new MediaPlayer();
        player.setDataSource("*****");
        player.setAudioStreamType(AudioManager.STREAM_MUSIC);           
        player.setOnPreparedListener(new OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                Log.i("In", "Prepared Listener");
                player.start();
            }
        });
        player.prepareAsync();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

public void onStopClick(View v) {

    if (player != null &amp;&amp; player.isPlaying()) {
        player.stop();
        player.release();
        player = null;
    }
}
</code></pre>

<p>}</p>

<p>Does anyone know what could be wrong with this simple code? 
Many Thanks
T</p>
