zoukankan      html  css  js  c++  java
  • android speakerphone/

    http://www.cnblogs.com/innost/archive/2011/01/22/1942149.html

    http://blog.sina.com.cn/s/blog_5418969101012yde.html 

    Android中文API(129) —— AudioManager(http://www.cnblogs.com/over140/archive/2011/08/07/2130393.html)

    http://www.cnblogs.com/over140/archive/2011/08/07/2130393.html

    Something like this might work on some devices (I've only tested in on an XPeria P):

    Class audioSystemClass = Class.forName("android.media.AudioSystem");
    Method setForceUse = audioSystemClass.getMethod("setForceUse", int.class, int.class);
    // First 1 == FOR_MEDIA, second 1 == FORCE_SPEAKER. To go back to the default
    // behavior, use FORCE_NONE (0).
    setForceUse.invoke(null, 1, 1);
    

    The combination FOR_MEDIA, FORCE_SPEAKER is typically only used internally to route the FM-radio audio to the loudspeaker (since the FM-radio requires you to have a wired headset / headphone plugged in to act as an antenna). Devices that don't have FM-radio functionality (or uses an alternative implementation) might ignore this combination of parameters, so this method would not work on such a device.

    You can acquire either a rear speaker or a front earpiece at time.

    If no accessory connected;

    Use audioManager.setMode(AudioManager.MODE_IN_CALL); & audioManager.setSpeakerphoneOn(false); to use front speaker/earpiece. But this would play audio in earpiece not on speaker. To use rear speaker, use audioManager.setMode(AudioManager.MODE_NORMAL); & audioManager.setSpeakerphoneOn(true);

    If accessory connected; Use audioManager.setMode(AudioManager.MODE_IN_CALL); & audioManager.setSpeakerphoneOn(false); to use front speaker/earpiece. But this would play audio in earpiece not on speaker. To use rear speaker, use audioManager.setMode(AudioManager.MODE_IN_CALL); & audioManager.setSpeakerphoneOn(true);

    Note: Make sure audioManager.setWiredHeadsetOn(boolean on) and audioManager.setBluetoothScoOn(boolean on) set to false to route audio via earpiece . And set either to true to route audio accordingly.

    if u just want to open your speakerphone on u just write this line in oncreate() of your activity.

    static AudioManager audioManager =  (AudioManager)getSystemService(Context.AUDIO_SERVICE);
    audioManager.setMode(AudioManager.MODE_IN_CALL);
    audioManager.setSpeakerphoneOn(true);


  • 相关阅读:
    Aboat join
    ajax 弹出层
    如何使用 BindingSource 绑定 ListBox,同时解决绑定 List<T> 后修改数据源不能同时刷新界面显示的问题
    Javascript 弹出层
    vs 2008 90 天 试用 破解
    c#的as类型转换详细理解,欢迎园友拍砖。
    Linux下定时切割Mongodb数据库日志并删除指定天数前的日志记录
    纠结了一天多的问题arithmetic overflow error converting expression to data type datetime
    关于开发Office2003AddIn问题
    为什么Scrum不行。。
  • 原文地址:https://www.cnblogs.com/SZLLQ2000/p/4909311.html
Copyright © 2011-2022 走看看