'Method onDestroy() in the background service
I have played two songs at the same time using the background service and I want to decide which one to finish in Method onDestroy() . How can I do this?
my code:
public void onCreate() {
super.onCreate();
player1 = MediaPlayer.create(this, R.raw.m1);
player2 = MediaPlayer.create(this, R.raw.m2);
player1.setLooping(true);
player2.setLooping(true);
}
@Override
public void onDestroy() {
super.onDestroy();
player1.stop();
player2.stop();
}
public void getTimestamp(String audio) {
if (audio.equals("player1")){
player1.start();
}else if (audio.equals("player2")){
player2.start();
}
}
public class MyBinder extends Binder {
MyService getService() {
return MyService.this;
}}}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
