728x90
어플리케이션에서 재생중인 음악껐다가 다시 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);
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;
728x90
'JAVA' 카테고리의 다른 글
cannot execute binary file (0) | 2013.08.26 |
---|---|
adt 다운로드 (0) | 2013.08.26 |
adb shell am start (0) | 2013.08.26 |
adb shell 어플 실행 (0) | 2013.08.26 |
라즈베리 파이 무선랜 (0) | 2013.08.16 |