어플리케이션에서 재생중인 음악껐다가 다시 app 종료시 음악 재생하는 코드입니다.
public static final String MUSIC_SERVICE_COMMAND = "com.android.music.musicservicecommand";
public static final String COMMAND = "command";
public static final String MUSIC_COMMAND_PAUSE = "pause";
public static final String MUSIC_COMMAND_PLAY = "play";
AudioManager manager = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
if(manager.isMusicActive()){
stopOtherMusic();
}
public void stopOtherMusic() {
isTheOtherMusicPlay = true;
Intent i = new Intent(MUSIC_SERVICE_COMMAND);
i.putExtra(COMMAND, MUSIC_COMMAND_PAUSE);
sendBroadcast(i);
}
public void playOtherMusic() {
if(!isTheOtherMusicPlay) return;
Intent i = new Intent(MUSIC_SERVICE_COMMAND);
i.putExtra(COMMAND, MUSIC_COMMAND_PLAY);
sendBroadcast(i);
isTheOtherMusicPlay = false;
}