android-audiomanager

Get info about audio, playing in another application

限于喜欢 提交于 2020-01-01 03:46:28
问题 How can i get info about source (filedesc. or uri) from which another application playing audio? In AudioManager there is only isMusicActive() method, which doesn't give any additional information. And because of it isn't my application, i doesn't have any MediaPlayer object. 回答1: Register a broadcast receiver for known action intents and handle the broadcast to show or do something with the track information, source: public class CurrentMusicTrackInfoActivity extends Activity { public static

Playing two sounds Simutaneosly

我怕爱的太早我们不能终老 提交于 2019-12-30 06:25:06
问题 I am trying to play two sounds simutaneosly in android.I have created two MediaPlayers and am using the code below.They are currently playing one after another.Or not exactly one after another but kinda delayed into eachother. private void playSound(){ if (mp1 != null) { mp1.release(); } if (mp2 != null) { mp2.release(); } mp1 = MediaPlayer.create(this, soundArray[0]); mp2 = MediaPlayer.create(this, soundArray[3]); mp1.start(); mp2.start(); } Thanks 回答1: Playing two digital sounds

How to increase the ringer & notification volume programmatically in android

和自甴很熟 提交于 2019-12-30 04:57:12
问题 I am trying to enable the ringer normal mode and increase the volume programmatically. AudioManager mobilemode = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE); // int streamMaxVolume = mobilemode.getStreamMaxVolume(AudioManager.STREAM_RING); switch (mobilemode.getRingerMode()) { case AudioManager.RINGER_MODE_SILENT: Log.i("MyApp","Silent mode"); mobilemode.setRingerMode(AudioManager.RINGER_MODE_NORMAL); mobilemode.setStreamVolume (AudioManager.STREAM_MUSIC,mobilemode

How to set volume for text-to-speech “speak” method?

那年仲夏 提交于 2019-12-30 00:40:10
问题 I'm at a lost. I want to be able to adjust the speak volume. Whatever I do, I can't increase its volume. How do I make it as loud as that found in the Android settings (as below)? System Settings -> Voice input and output -> Text-to-Speech settings -> Listen to an example My code at this moment is: AudioManager mAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); mAudioManager.setSpeakerphoneOn(true); int loudmax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM

Detect whether headset has microphone

此生再无相见时 提交于 2019-12-29 05:33:14
问题 I need to detect whether the plugged in wired headset has microphone or not. I can check if a headset is plugged in using isWiredHeadSetOn(), but for microphone does not seem to be such a method in AudioManager class. I have found some suggestions using ACTION_HEADSET_PLUG, but I am interested to find out this information even if the headset has been plugged in before opening my application, this event won't be fired during the lifetime of my app. Any ideas regarding this issue? Thank you in

Playing sound over speakers while playing music through headphones

帅比萌擦擦* 提交于 2019-12-28 06:24:48
问题 I have an AudioTrack streaming via headphones. I have to send a SoundPool to built-in speakers only, without interrupting the AudioTrack playing over the headphones. Any hacks gangsters? 回答1: Many Android devices use a single output thread in the AudioFlinger / audio HAL for all local playback (earpiece, speaker, wired headset/headphones), making different routing of two tracks simultaneously impossible (which is why on many devices the media streams are forcibly muted if a notification is

How to mute audio in headset but let it play on speaker programmatically?

孤街醉人 提交于 2019-12-28 04:21:08
问题 I am searching a work-around for my problem specified in this question: How to disable the wired headset programmatically in Java As mentioned there, I am getting audio in both my speakers and headphones. Can someone please tell me how to mute the audio in the headset programmatically , while letting it play undiminished on speaker? 回答1: AudioManager am = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); am.setMode(AudioManager.MODE_IN_CALL); am.setSpeakerphoneOn(true); And then

AudioManger doesn't Work Application Crashes

帅比萌擦擦* 提交于 2019-12-25 18:38:14
问题 I'm working on an application .. but Audiomanager is not working i can't see any error my application got crash on phone I'm using AudioManager in BroadCastReciver Class when sms recive and text of sms is same of the particular text i've set the volume should be change silent to Normal mode. if(message.equals(pwd)) { AudioManager au; au = (AudioManager)getSystemService(Context.AUDIO_SERVICE); au.setRingerMode(AudioManager.RINGER_MODE_NORMAL); // Show Alert int duration = Toast.LENGTH_LONG;

Android N: checking for DND state changed before updating checkbox preference

瘦欲@ 提交于 2019-12-25 09:03:04
问题 My app sets the ringer mode to silent but with Android N I get a java.lang.SecurityException: Not allowed to change Do Not Disturb state . I followed the steps from this post and the following code will open an activity which contains a toggle button for enabling the permission to change the ringer mode. This activity can be "backed" from without the enabling of the permission. Intent intent = new Intent( android.provider.Settings .ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS); startActivity

How to detect the BT headset or wired headset in android

╄→гoц情女王★ 提交于 2019-12-25 08:58:52
问题 In my application i want to detect the BT headset or wired headset in android. I refer http://developer.android.com/guide/topics/connectivity/bluetooth.html code from this link. They mention that only 3.0 and above version of android can support the BluetoothHeadset and BluetoothProfile class. Which is helpful to detect the BT headset. Now i want the same functionality in 2.2(froyo).So please any one can tell me how to do the same? Thanks in advance. 回答1: You can use the 3.0 API's in 2.2 via