I’am starting a MediaPlayer Service via an Activity, exactly with a button:
startService(new Intent(this, PlayerService.class));
My Service Executes in onCreate the MediaPlayer
@Override
public void onCreate() {
mp = new MediaPlayer();
mp.setOnPreparedListener(this);
prepareMediaPlayer(); //prepares the MediaPlayer, setDataSource and so on
Log.d(TAG, "onCreate Service");
}
I can get out of the activity with the homebutton and the stream plays fine, but if I get back via backButton the stream stops. And begins to start again. With other DataSource.
Can you help me why?
I got no error!
create an foreground service (with
setForeground()) solved it.