설.현.아빠
음악재생중 내 어플 진입시 음악 끄기. 본문
AudioManager
am=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
if(am.isMusicActive())
{
long
eventtime = SystemClock.uptimeMillis();
Intent downIntent = new
Intent(Intent.ACTION_MEDIA_BUTTON, null);
KeyEvent downEvent = new KeyEvent(eventtime, eventtime,
KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, 0);
downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent);
sendOrderedBroadcast(downIntent,
null);
Intent upIntent = new
Intent(Intent.ACTION_MEDIA_BUTTON, null);
KeyEvent upEvent = new KeyEvent(eventtime, eventtime,
KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, 0);
upIntent.putExtra(Intent.EXTRA_KEY_EVENT,
upEvent);
sendOrderedBroadcast(upIntent, null);
}
'안드로이드 > Audio' 카테고리의 다른 글
[개발 Tip] 현재 연주중인 오디오 어플을 음소거 하기 (0) | 2011.02.11 |
---|---|
Android Volume Test (0) | 2011.02.11 |