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 ...
随机推荐
- Docker应用之容器
容器是独立运行的一个或一组应用,以及他们的运行态环境 1.启动容器(基于镜像新建一个容器并启动或将终止状态的容器重新启动) run后面添加--name参数可以指定容器的名称,否则系统默认会给名称:使用 ...
- python commands模块在python3.x被subprocess取代
subprocess 可以执行shell命令的相关模块和函数有: os.systemos.spawnos.popen --废弃popen2.* --废弃commands.* --废弃,3.x中被移除 ...
- 【代码审计】BootCMS v1.1.3 文件上传漏洞分析
0x00 环境准备 BootCMS官网:http://www.kilofox.net 网站源码版本:BootCMS v1.1.3 发布日期:2016年10月17日 程序源码下载:http://w ...
- Ansible Playbook 使用变量
如何在 Playbook 中定义并使用变量: vars: - user: "test" # 定义变量 tasks: - name: create user user: name=& ...
- 第1章 Ansible 简介
1. Ansible 优点 (1) 易读的语法:Ansible使用playbook作为配置管理脚本,playbook是基于YAML开发的,是一种易于读写的数据格式(2) 远程主机无须安装任何依赖:被A ...
- 队列Queue中add()和offer()的区别?
区别:两者都是往队列尾部插入元素,不同的时候,当超出队列界限的时候,add()方法是抛出异常让你处理,而offer()方法是直接返回false
- 微信小程序--消息推送配置Token令牌错误校验失败如何解决
微信开放第三方API接口, 申请地址: https://mp.weixin.qq.com/advanced/advanced?action=interface&t=advanced/inter ...
- 【十大算法实现之KNN】KNN算法实例(含测试数据和源码)
KNN算法基本的思路是比较好理解的,今天根据它的特点写了一个实例,我会把所有的数据和代码都写在下面供大家参考,不足之处,请指正.谢谢! update:工程代码全部在本页面中,测试数据已丢失,建议去UC ...
- margin-left:10px; 不同浏览器距离为什么不一样?
这是一个ie的bug.. 如果你设置margin对象是浮动的.ie就会把你设置的值双倍处理..可以设置浮动对象的 display:inline 解决
- MFC 常见问题
一 常见变量获得 CDC * cDc=GetDC(); HDC m_Screenhdc = this->GetDC()->m_hDC; // 整个窗口客户区的坐标 this->Ge ...