android,nullpointerexception,android-audiomanager
It's an Android bug it's not your code. Put a try/catch block in your code to avoid the crash.
Music player is not standard thing on Android and vendors can come with different app than others (i.e. Sony is good exapmple). Controlling media app can be doable but final effect depends on what app is really installed (and used, as user can have more than one). You may be...
java,android,android-audiomanager
You can mute the sound when your app starts and unmute when it finishes using AudioManager @override public void onResume(){ super.onResume(); // this mute the Sound AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE); mgr.setStreamMute(AudioManager.STREAM_SYSTEM, true); } @override public void onPause(){ super.onPause(); AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE); mgr.setStreamMute(AudioManager.STREAM_SYSTEM, false); } ...
Yes there is a way. MediaPlayer.setVolume(float leftVolume,float rightVolume). In the following snippet we're playing an .mp3 file contained in assets folder(note if you have multiple files in the folder you should check this answer). By pressing one of the Button objects the song is played only out of the left...
android,android-bluetooth,android-audiomanager,android-audiorecord
Including the Android OS versions in your question might be helpful. I've encountered issues with Bluetooth in 4.4 which were are present in 4.1 or 5.0. The specific problem I've seen is a bluetooth disconnect after a short period of time with Android 4.4. Commands from my headset to my...
android,android-notifications,volume,android-audiomanager
Replace the line mobilemode.setStreamVolume (AudioManager.STREAM_MUSIC,mobilemode.getStreamMaxVolume(AudioManager.STREAM_MUSIC),0); with below line mobilemode.setStreamVolume(AudioManager.STREAM_RING,audioManager.getStreamMaxVolume(AudioManager.STREAM_RING),0); ...
android,audio-recording,android-audiomanager,android-audiorecord,audiotrack
It is a simple fix but might be an Android issue, please refer to my fix below if (track != null && track.getState() != AudioTrack.STATE_UNINITIALIZED) { if (track.getPlayState() != AudioTrack.PLAYSTATE_STOPPED) { try{ track.stop(); }catch (IllegalStateException e) { e.printStackTrace(); } } track.release(); am.setMode(AudioManager.MODE_NORMAL); //track.release(); //track = null; } and OnCreate private...
android,android-mediaplayer,keyevent,android-audiomanager
dispatchMediaKeyEvent is inherited from AudioManager class. You're referencing it as a boolean. http://developer.android.com/reference/android/media/AudioManager.html#dispatchMediaKeyEvent(android.view.KeyEvent) This is how a code using this event should look like AudioManager am = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); long eventtime = SystemClock.uptimeMillis() - 1; KeyEvent downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, 0);...
android,performance,android-audiomanager,android-audiorecord
Well, I guess it is card reader or something like that. I have the same problems, and I would suggest you to contact with manufacturer and ask for specs. Other than that, AudioManager audioManager = (AudioManager)this.getSystemService(Context.AUDIO_SERVICE); String rate = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE); String size = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER); Log.d("Buffer Size and sample rate", "Size...
android,service,nullpointerexception,android-service,android-audiomanager
I have an idea today.... To declare AudioManager audio_mng as static.... That works ! If you have other explanation or another answer or why that happened please answer. Thank you for your interest...
android,android-audiomanager,android-vibration
You can set the ringer method to RINGER_MODER_NORMAL (Sound and vibrate on) and separately set the vibrate setting to VIBRATE_SETTING_OFF(turn off vibrate completely) OR VIBRATE_SETTING_ONLY_SILENT.(Vibrate only if the mode is silent) as below: To turn off ringtone vibrations: setVibrateSetting (AudioManager.VIBRATE_TYPE_RINGER,AudioManager.VIBRATE_SETTING_OFF) To turn off notification vibrations: setVibrateSetting (AudioManager.VIBRATE_TYPE_NOTIFICATION,AudioManager.VIBRATE_SETTING_OFF) UPDATE:To get the...
Since I couldn't find the answer, I came up with the work-around by actually playing the ringer sound in my service.
I was getting wrong values for the ringer volume. The method getStreamVolume (int streamType) gets an int and returns int. When you write: alarm = amanager.getStreamVolume(amanager.getStreamVolume(AudioManager.STREAM_ALARM)); you're actually getting the volume of the alarm (lets say it is X), and then passing to alarm the value alarm = amanager.getStreamVolume(X); so...
android,android-audiomanager,ondestroy
Use a service like: public class FirstService extends Service { private AudioManager audioManager; @Override public IBinder onBind(Intent arg0) { return null; } @Override public void onDestroy() { super.onDestroy(); audioManager.setSpeakerphoneOn(false); //Turn of speaker } } public void onDestroy () Added in API level 1 Called by the system to notify a...
android,audio,soundpool,android-audiomanager,headphones
Alternatively, if you initialize your SoundPool to STREAM_VOICE_CALL, as: SoundPool spool = new SoundPool(1,AudioManager.STREAM_VOICE_CALL, 0) then also your audio should be routed to loudspeaker with any of the way you have mentioned above. I tried and its working on phones even without default FM....
android,android-mediaplayer,android-audiomanager
Ok it looks like the issue is Android 5.0.1's experimental MediaPlayer called NuPlayer. NuPlayer is being enabled by default on all Android 5.0.1 devices and is only disabled through Developer Options. I've filed a bug against Android here: https://code.google.com/p/android/issues/detail?id=94069&thanks=94069&ts=1420659450 Here's a sample email you can send your users when they...
android,output,android-audiomanager,speaker
I try this and it's working for my case : class AudioSystem { private static final int REFLECTION_ERROR = -999; private static final String DEVICE_OUT_SPEAKER = "DEVICE_OUT_SPEAKER"; private static final String DEVICE_OUT_EARPIECE = "DEVICE_OUT_EARPIECE"; private static final String DEVICE_OUT_WIRED_HEADPHONE = "DEVICE_OUT_WIRED_HEADPHONE"; Class<?> mAudioSystem; protected AudioSystem() { try { mAudioSystem =...