Created
May 19, 2016 07:50
-
-
Save kazuman519/f8914f0b63884993015474b3556de6c5 to your computer and use it in GitHub Desktop.
【Android】他アプリで音楽が再生されているか知りたい 自アプリからプレイヤーを操作したい ref: http://qiita.com/kazuman519/items/f470851b7fb7cb75794e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); | |
| if (audioManager.isMusicActive()) { | |
| // 再生中!! | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager | |
| if (audioManager.isMusicActive) { | |
| // 再生中!! | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Intent intent = new Intent("com.android.music.musicservicecommand"); | |
| // play: 再生, pause: 停止, next: 次へ, preview: 前へ | |
| intent.putExtra("command", "pause"); | |
| context.sendBroadcast(intent); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val intent = Intent("com.android.music.musicservicecommand") | |
| // play: 再生, pause: 停止, next: 次へ, preview: 前へ | |
| intent.putExtra("command", "pause") | |
| context.sendBroadcast(intent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment