android-audiomanager

Audio stream stays on earpiece after using AudioManager

╄→гoц情女王★ 提交于 2019-12-25 03:08:50
问题 After I use the Android AudioManager to set SCO ON and speakerphone ON, then I return it back to where it started, the media stream will then stay on earpiece instead of the phones speaker. Here is where I make the changes to route a stream through the SCO speakerphone (which all works great) if (am2.isBluetoothScoAvailableOffCall()) { am2.startBluetoothSco(); } if(!am2.isSpeakerphoneOn()){ speakerPhoneWasOn = false; am2.setSpeakerphoneOn(true); } myHash.put(TextToSpeech.Engine.KEY_PARAM

Change Android Audio Record Default input Source

一笑奈何 提交于 2019-12-23 10:19:55
问题 I am currently writing an app that calls for the recording and real time processing of audio data. For this, I am using the AudioRecord class. This works all well and good, except the default setting for recording audio on my primary testing device, a galaxy nexus, is to record from the back speaker. I am assuming most phones default record source will be the back, or bottom microphones, because when you are using the phone to call, your mouth is near the bottom. However, my app requires that

Change Android Audio Record Default input Source

旧巷老猫 提交于 2019-12-23 10:18:26
问题 I am currently writing an app that calls for the recording and real time processing of audio data. For this, I am using the AudioRecord class. This works all well and good, except the default setting for recording audio on my primary testing device, a galaxy nexus, is to record from the back speaker. I am assuming most phones default record source will be the back, or bottom microphones, because when you are using the phone to call, your mouth is near the bottom. However, my app requires that

How to turn off vibration of Notifications in android

筅森魡賤 提交于 2019-12-23 04:14:17
问题 I'm developing an app that handles sound and vibration of apps' notifications . I am listening to notifications using NotificationListenerService . I am able to turn on or off notification's sound using AudioManager as follows: // It turns off notification's sound myAudioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true); // It turns on notification's sound myAudioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION, false); I have also tried to turn on or off notification's

How to pass a parameter to a subclass of BroadcastReceiver?

て烟熏妆下的殇ゞ 提交于 2019-12-22 03:42:07
问题 I managed to get my headset buttons get recognized by my app when pressed, but one of the buttons needs to call a method that's in MyCustomActivity. The problem is onReceive's 1st parameter is a Context that cannot be cast to Activity and using a MyCustomActivity's inner class won't work in Android 4.1 unless it is static (which has the same problem of inability to access MyCustomActivity's method. So the only option left for me (in order to support both 2.x and 4.1) is to pass the activity

How to route default audio to ear piece when headphones are connected?

跟風遠走 提交于 2019-12-22 00:19:59
问题 I am developing an app in which we need to use the headphone jack as a button only. Requirement : Play the default audio (calling) via earpiece when headsets are connected (no need of audio through headphones) There are many example of routing audio through speaker and headphones and also bluetooth headsets but nothing about routing the audio through ear speakers of devices if headsets are connected. I have tried a lot and some links are Android : Force audio routing (not working in my

Alternative to the deprecated AudioManager.isWiredHeadsetOn?

大城市里の小女人 提交于 2019-12-21 04:32:06
问题 The method AudioManager.isWiredHeadsetOn() is deprecated from api level 14, how do we now detect if a wired headset is connected? 回答1: The documentation's deprecation message states: Use only to check is a headset is connected or not. So I guess it is okay to keep using it to check whether or not a wired headset is connected, but not to check whether or not audio is being routed to it or played over it. 回答2: This is my solution: private boolean isHeadsetOn(Context context) { AudioManager am =

Calling setVolumeControlStream from a Service

徘徊边缘 提交于 2019-12-20 17:35:14
问题 I need to call setVolumeControlStream from a service that plays some sound via STREAM_SYSTEM . Obviously in an Activity that is no problem, but how can I do this with a service? 回答1: From the looks of it, this isn't possible the way you are trying to do it. As said in the android reference The suggested audio stream will be tied to the window of this Activity Hence with a service that has no activity, there is no window to tie the audio stream to. However, It looks like you should be able to

How to play or resume music of another music player from my code

北战南征 提交于 2019-12-20 08:46:19
问题 In my Android app I want to play or resume the played music after I pause it. I got my app to pause the music by sending a broadcast, but I can't get it to play or resume the music. Here is the code to pause: Intent i = new Intent("com.android.music.musicservicecommand"); i.putExtra("command", "pause"); sendBroadcast(i); 回答1: Here is what I have discovered after testing these. I have tried and verified these commands to work just fine. // pause Intent i = new Intent("com.android.music

What permissions are needed to programmatically mute a phone call, from a background app?

梦想与她 提交于 2019-12-20 03:07:43
问题 I have an Android app that happens to be running in the background on the user's Android phone, while the user is speaking on a phone call that someone placed to the user. At a certain point, my app would like to silence the audio from the phone call and play its own audio. Moreover, I'd like to do this without disrupting the user's speech. What permission does my app need to have, to do this? Is there any permission that's available to third-party apps that is sufficient to let my app do