How to "reconnect" to a service with activity

I'm starting to make an Android app that broadcasts music from a radio station. Therefore, I have an activity that extracts information about the artist, title and album cover. And also everything related to the UI (play, pause, exit and change the bandwidth). Everything works fine when I first run the application, but when I clicked the home button and I restarted the Android application, recreate the action (passing onResume, etc.). But my service with musicPlayer continues to play, and then I can’t send instructions from this operation, because it cannot access the Service. So my question is when activity is recreated using onResume, etc., How can we send information to a service. Here's how I create a service and send it information:

onCreate(){
...
Intent intent = new Intent(getApplicationContext(), Play.class);
    intent.putExtra("play", true);
    intent.putExtra("pause", false);
    intent.putExtra("stop", false);
    intent.putExtra("artist", artist);
    intent.putExtra("title", title);
    intent.putExtra("speed", "low");
    intent.putExtra("restart", restart);
    startService(intent);
    restart = false;
...
}

, onBind(), , , .

, .

+3

All Articles