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);
android speakerphone/的更多相关文章
- Android Audio Play Out Channel
1: 7嘴8舌 扬声器, 耳机, 和听筒 就是通过: audiomanager.setmode(AudioManager.MODE_IN_COMMUNICATION)audiomanager.setS ...
- Android 各版本信息 (维基百科)
The following tables show the release dates and key features of all Android operating system updates ...
- 【Android Developers Training】 46. 处理音频外放设备
注:本文翻译自Google官方的Android Developers Training文档,译者技术一般,由于喜爱安卓而产生了翻译的念头,纯属个人兴趣爱好. 原文链接:http://developer ...
- Android项目中的config.xml文件 “config.xml”
Android应用程序需要保存一些配置时,可以将这些配置项放置到values/config.xml文件中. 实例分析: <?xml version="1.0" encodin ...
- 【转】解决在Android设备播放音频与其他应用重音的问题,并监听耳机的控制按钮
概述 在安卓开发中免不了需要播放一点音乐了,音频了.但是这时候有别的应用正在播放,这时候就会出现重音的现象,完全影响用户体验,我们的项目就遇上了这样的尴尬,然后查找了一些文档,记录一下: 管理音频焦点 ...
- 强烈推荐:Android史上最强大的自定义任务软件Tasker
强烈推荐:Android史上最强大的自定义任务软件Taskerhttp://bbs.mumayi.com/thread-28387-1-1.html(出处: 木蚂蚁手机乐园) Android上的Tas ...
- Android audioManager
Android audioManager AudioManager provides access to volume and ringer mode control. 获取对象 Use Contex ...
- android MVP模式思考
在软件开发设计中,有多种软件设计模式,如web开发中经典的MVC, 将后台分为三层:Model层,View层和Controller层,其中,Model主要是数据处理,如数据库,文件,或网络数据等:Vi ...
- 【原】Android热更新开源项目Tinker源码解析系列之三:so热更新
本系列将从以下三个方面对Tinker进行源码解析: Android热更新开源项目Tinker源码解析系列之一:Dex热更新 Android热更新开源项目Tinker源码解析系列之二:资源文件热更新 A ...
随机推荐
- 中间件安全加固之Jboss
JBoss 的安全设置 1) jmx-console A.jmx-console登录的用户名和密码设置 默认情况访问 http://localhost:8080/jmx-console 就可以浏览jb ...
- iOS开发--设置UIButton
1.设置title [btn setTitle: @"search" forState: UIControlStateNormal]; 2.设置字体 //[btn setFont: ...
- Jsoup(二)-- Jsoup查找DOM元素
一.Jsoup查找DOM元素的方法 getElementById(String id) 根据id 来查询DOM getElementsByTag(String tagName) 根据tag 名称来查询 ...
- python对oracle数据库的操作
1 Oracle数据库 1.1 Oracle环境配置&客户端连接 1.1.1 下载安装Oracle绿色版客户端instantclient: 到o ...
- vue回到顶部的事件
其实只需要一句代码就好了: document.documentElement.scrollTop = document.body.scrollTop = ;
- Xshell 5 免费版本安装过程
发现本机的Xshell 5过期了用不了.在百度里搜索,下载安装后还是不可以使用.需要购买注册,后寻的一方法,分享给大家. 1.官网 进入官网,然后点击Download下方的Free License菜单 ...
- struts1的配置文件详解11111
要想使用Struts,至少要依靠两个配置文件:web.xml和struts-config.xml.其中web.xml用来安装Struts框架.而struts-config.xml用来配置在Struts ...
- 【cs229-Lecture14】主成分分析法
本节课内容: 因子分析 ---因子分析中的EM步骤的推导过程 主成份分析:有效地降低维度的方法 因子分析 混合高斯模型的问题 接下来讨论因子分析模型,在介绍因子分析模型之前,先看高斯分布的另一种写法, ...
- 【Spring Boot && Spring Cloud系列】那些Spring Boot中踩过的坑
一.不连接数据库启动springboot报错 Cannot determine embedded database driver class for database type NONE 原因:Spr ...
- Elasticsearch学习之深入搜索四 --- cross-fields搜索
1. cross-fields搜索 一个唯一标识,跨了多个field.比如一个人,标识,是姓名:一个建筑,它的标识是地址.姓名可以散落在多个field中,比如first_name和last_name中 ...