android-audiomanager

Android: MediaPlayer AUDIOFOCUS_LOSS & setOnErrorListener() issue

限于喜欢 提交于 2019-12-19 09:26:22
问题 I'm creating a music player app. In that I am checking if my application loses AudioFocus then the playback will stop. But this is raising one issue that when I play a track - then stop it and - then play a track again, switch case AudioManager.AUDIOFOCUS_LOSS is getting called in which I've stopped the player as it is losing focus. So my own app is losing focus to itself. Obviously, these were not my intentions. I wanted it to get called when some other music player requested focus. private

AudioManager.isWiredHeadsetOn() is not working in android

北城余情 提交于 2019-12-19 07:55:16
问题 I want to check whether heaset is plugged in or not... I did it like this AudioManager am = (AudioManager)getSystemService(AUDIO_SERVICE); Log.i("am.isWiredHeadsetOn()", am.isWiredHeadsetOn()+""); But i am always getting false value... Why is this happening? 回答1: It looks like this is a bug. You will always get false when calling isWiredHeadsetOn unless your add MODIFY_AUDIO_SETTINGS permission to AndroidManifest.xml : <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /

What do the the flag parameter means and range of possible min and max of droid device

北城余情 提交于 2019-12-19 03:14:54
问题 I want to know what is flag(or what are the possible values for flag) in audiomanager.setStreamVolume (int streamType, int index, int flags); I know we can get the maximum stream using audiomanger.getMaxStream(audioManager.getStreamMax(AudioManager.STREAM_MUSIC)); But in some device it gives 13,15, it depends on Android version or device hardware and what is it range(minimum possible value, maximum possible value) Sets the volume index for a particular stream. This method has no effect if the

Headphone Jack Listener Android

天大地大妈咪最大 提交于 2019-12-19 02:48:28
问题 Does anyone know how I can detect if the headphone jack on a device is unplugged on Android? I have a music player and I need to pause the music when the headphones are unplugged. The closest thing I have found is using the AudioManager . Is that the right direction to go? 回答1: This is what I ended up doing: private class NoisyAudioStreamReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (AudioManager.ACTION_AUDIO_BECOMING_NOISY.equals

Android MediaPlayer - how to play in the STREAM_ALARM?

旧城冷巷雨未停 提交于 2019-12-18 04:01:54
问题 I've tried settings the audio stream of the media player in my application using the following code but when I do this I hear no sound in the emulator. If I don't set the stream for the player then the audio plays fine. I'm sure I'm using this wrong but cannot workout how, any help? MediaPlayer player = MediaPlayer.create(getApplicationContext(), R.raw.test_audio); AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE); audioManager

Android Context Memory Leak ListView due to AudioManager

主宰稳场 提交于 2019-12-18 02:19:11
问题 I have a ListView and I would expect it to be cleared from memory when the activity finishes. However, it appears that it is leaking. When I check the Memory Dump, and get the pathToGC for the ListView I get the following, Class Name | Shallow Heap | Retained Heap android.widget.ExpandableListView @ 0x4063e560 | 768 | 39,904 |- list, mList com.hitpost.TeamChooser @ 0x405f92e8 | 176 | 1,648 | '- mOuterContext android.app.ContextImpl @ 0x40657368 | 160 | 304 | '- mContext android.media

Android - can I mute currently playing audio applications?

橙三吉。 提交于 2019-12-17 15:38:38
问题 Hi I'm new to this. My self-teaching project is a small application which plays an audio news stream. To be effective, the application really needs to interrupt any currently playing media players (eg: Last FM, Imeem, music player, Spotify etc). I don't know what will be playing or what application will be playing it, but I want to ask them all to pause until I've done. Sounds rather bold, I know, but it must be possible, because when there's an incoming call, that's basically what happens.

How does setMicrophoneMute() work?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 10:27:25
问题 I have been trying to use Android's AudioManager.setMicrophoneMute() without much success. That is, it simply refuses to mute the microphone, no matter what I do. I searched the web for some clues and I found several references reporting similar experience: AudioManger.setMicrophoneMute functionality not working?? setMicrophoneMute(boolean) doesn't work on some devices Unable to mute the microphone in Android Which begs the question: Does AudioManager.setMicrophoneMute() work at all? Is it

How does setMicrophoneMute() work?

こ雲淡風輕ζ 提交于 2019-12-17 10:27:18
问题 I have been trying to use Android's AudioManager.setMicrophoneMute() without much success. That is, it simply refuses to mute the microphone, no matter what I do. I searched the web for some clues and I found several references reporting similar experience: AudioManger.setMicrophoneMute functionality not working?? setMicrophoneMute(boolean) doesn't work on some devices Unable to mute the microphone in Android Which begs the question: Does AudioManager.setMicrophoneMute() work at all? Is it

How do you get/set media volume (not ringtone volume) in Android?

让人想犯罪 __ 提交于 2019-12-17 08:29:41
问题 Is there a way to get/set media volume? I have tried the following: AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); int currentVolume = audio.getStreamVolume(AudioManager.STREAM_RING); but it returns the ringtone volume. 回答1: Instead of AudioManager.STREAM_RING you shoul use AudioManager.STREAM_MUSIC This question has already discussed here. 回答2: private AudioManager audio; Inside onCreate: audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); Override