android-audiomanager

How to set volume in decibels using my android mobile application?

♀尐吖头ヾ 提交于 2019-12-08 04:00:30
问题 I am working on a mobile app, where i need to play the sound file. On volume button press, i need to increase/decrease the volume through my app. I am using Media player to play and using SetVolume(left, right) function to set the volume. MediaPlayer mp; float left = 0.0f; float right = 0.6f; public void OnPlay(View v){ mp = MediaPlayer.create(this, R.raw.twofiftybeep); audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mp.start(); mp.setOnCompletionListener(new

Stop audio playing when another app's audio comes in

别等时光非礼了梦想. 提交于 2019-12-08 02:19:59
问题 I would like to know how do I implement the behaviour, so that my radio streaming would stop playing if other audio would come in to play - for instance, user starts playing music, makes a call etc. In other words, how does my ExoPlayers knows that other audio is being played, or if it doesn't, do I have to listen for mediaplayer and call events? 回答1: Here is an example i made for an audio state manager , you can use it as a template. (created in 2016) As per the question - You need to use an

Android setStreamVolume for STREAM_RING doesn't always work while RINGING

末鹿安然 提交于 2019-12-07 22:49:47
问题 I am trying to do this simple App that allows the phone to ring but not to play a sound when receiving notifications under Android 4 (ICS). In order to do that I set the ring/notification stream to 0 (mute). When receiving a call I set the ring volume to max (p.e. 7) and then, on Idle, I turn it back to 0 (mute). To do that I use this simple code. public class ReceiverClass extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if ("android.intent.action

Audiomanager Speaker not working

ε祈祈猫儿з 提交于 2019-12-07 11:52:56
问题 I'm trying to enable the speaker while I am in a call: final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audioManager.setSpeakerphoneOn(true); I tried to check after the setSpeakerphoneOn() the audiomanager and get that the speaker is still not on by asking isSpeakerphoneOn() audioManager.isSpeakerphoneOn(); In my log I can see some errors that I can't understand: E/AudioManager: Don't setBluetoothScoOn-PackageName: com.myapp.app on = false E

Increase volume of recording Android AudioRecord

青春壹個敷衍的年華 提交于 2019-12-06 19:30:09
问题 I'm using AudioRecord and lame to record mic input to a mp3 sample for 12 seconds. The audio is recorder as expected but I realized the volume is too low. Is there a way to increase the volume of the recording? 回答1: There is no gain settings in the audioRecord class to play with, so you cannot control the volume of the audio being recorded. The low volume of the audio is related to the hardware and varies from device to device. Here are a few options you can try. 1) try opening in the audio

How to turn off vibration of Notifications in android

懵懂的女人 提交于 2019-12-06 15:37:30
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 vibration with following code but it didn't work on my phone which has Android KitKat 4.4.4 // to turn off

How to set volume in decibels using my android mobile application?

三世轮回 提交于 2019-12-06 15:35:05
I am working on a mobile app, where i need to play the sound file. On volume button press, i need to increase/decrease the volume through my app. I am using Media player to play and using SetVolume(left, right) function to set the volume. MediaPlayer mp; float left = 0.0f; float right = 0.6f; public void OnPlay(View v){ mp = MediaPlayer.create(this, R.raw.twofiftybeep); audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mp.start(); mp.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { // Playing the file continuously mp

Android setStreamVolume for STREAM_RING doesn't always work while RINGING

只谈情不闲聊 提交于 2019-12-06 13:34:07
I am trying to do this simple App that allows the phone to ring but not to play a sound when receiving notifications under Android 4 (ICS). In order to do that I set the ring/notification stream to 0 (mute). When receiving a call I set the ring volume to max (p.e. 7) and then, on Idle, I turn it back to 0 (mute). To do that I use this simple code. public class ReceiverClass extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if ("android.intent.action.PHONE_STATE".equals(intent.getAction())) { String state = intent.getStringExtra(TelephonyManager.EXTRA

Changing the Vibrate settings in Jelly Bean, Android

核能气质少年 提交于 2019-12-06 11:50:03
问题 I am looking for how we change the vibrate settings in Jelly Bean. I found that all the pre-JB vibrate settings have been deprecated, but don't see any new AudioManager.[change the vibrate settings] code anywhere. There is a setting "Vibrate when ringing" which I would like to know how to play with. Thanks for you help. 回答1: In android4.1 you can use this to control "vibrate & ringing" Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, enable ? 1 : 0); 回答2: From

how to change ringer mode in background(Vibrate or Silent)

耗尽温柔 提交于 2019-12-06 11:24:16
I'm trying to write a program in which user can set time that will change ringer mode to vibrate or normal in background. When I set the start time it's working but at the end time it's not changing and device continuing vibrate mode. I just want, at the start time phone would be in vibrate and at end time phone would go back into the silent mode. MainActivity.java public class MainActivity extends Activity { private PendingIntent pendingIntent; private AlarmManager alarmManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R