gpt4 book ai didi

android - 如何让音乐从接收器而不是扬声器播放?

转载 作者:行者123 更新时间:2023-12-03 02:26:24 27 4
gpt4 key购买 nike

(通过说接收器,我指的是您正常听到电话时的声音。)
有人给了下面的代码,这是行不通的。有什么帮助吗?

  Object obj = new Object();
Method method;
try {
method = Class.forName("android.media.AudioSystem").getMethod(
"setDeviceConnectionState", new Class[] { Integer.TYPE,Integer.TYPE,
String.class });
method.invoke(obj, new Object[] {num,1,""});
} catch (Exception e) {
e.printStackTrace();
Log.i(TAG, e.toString());
}

Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(android.content.Intent.ACTION_VIEW);
String type = getMIMEType(f);
intent.setDataAndType(Uri.fromFile(f), type);
startActivity(intent);

最佳答案

m_amAudioManager.setMode(AudioManager.MODE_IN_CALL);

关于android - 如何让音乐从接收器而不是扬声器播放?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4363832/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com