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 ...
随机推荐
- ios开发之--VC的生命周期
当一个视图控制器被创建,并在屏幕上显示的时候. 代码的执行顺序 1. alloc 创建对象,分配空间 2.init (initWit ...
- iOS iTuns Connect官方配置教程
iTunes Connect 开发者指南 (iTunes Connect Developer Guide): https://developer.apple.com/library/ios/docum ...
- Weblogic(CVE-2017-10271)漏洞复现
WebLogic XMLDecoder反序列化漏洞(CVE-2017-10271) 漏洞编号:CVE-2017-10271 漏洞描述:WebLogic WLS组件中存在CVE-2017-10271远程 ...
- CentOS7安装ipython
python版本:2.7.5 yum install -y python2-pip.noarchyum install -y python-develpip install ipython==5.4. ...
- mac 下搭建Elasticsearch 5.4.3分布式集群
一.集群角色 多机集群中的节点可以分为master nodes和data nodes,在配置文件中使用Zen发现(Zen discovery)机制来管理不同节点.Zen发现是ES自带的默认发现机制,使 ...
- iis下的php环境的配置
1. 参考园友文章: http://www.cnblogs.com/zengxiangzhan/archive/2010/03/05/1679286.html 2.另外还可以参考一下文章: http: ...
- 【LeetCode OJ】Search Insert Position
题目:Given a sorted array and a target value, return the index if the target is found. If not, return ...
- Swift - 类型转换(as as! as?)
swift 类型转换 一,as 1,as使用场合 (1)从派生类转换为基类,向上转型(upcasts) class Animal {} class Cat: Animal {} let cat = C ...
- sklearn包学习
1首先是sklearn的官网:http://scikit-learn.org/stable/ 在官网网址上可以看到很多的demo,下边这张是一张非常有用的流程图,在这个流程图中,可以根据数据集的特征, ...
- 【Spring Boot && Spring Cloud系列】Spring Boot的启动器Starter
Spring Boot的内置Servlet Container: Name Servlet Version Java Version Tomcat8 3.1 Java 7+ Tomcat7 3.0 J ...