Andorid_当前应用停止其他应用播放音频
作者:
XII01 | 来源:发表于
2020-06-16 10:23 被阅读0次 /**
* 停止音乐播放
*
* @param context
*/
public static void pauseMusic(Context context) {
if (context == null) {
return;
}
Intent freshIntent = new Intent();
freshIntent.setAction("com.android.music.musicservicecommand");
freshIntent.putExtra("command", "pause");
context.getApplicationContext().sendBroadcast(freshIntent);
}
/**
* 播放音乐
*
* @param context
*/
public static void playMusic(Context context) {
Intent freshIntent = new Intent();
freshIntent.setAction("com.android.music.musicservicecommand");
freshIntent.putExtra("command", "togglepause");
context.getApplicationContext().sendBroadcast(freshIntent);
}
本文标题:Andorid_当前应用停止其他应用播放音频
本文链接:https://www.haomeiwen.com/subject/grslxktx.html
网友评论