2

I'd like to somehow stop Bluetooth from changing the volumes when it connects and disconnects. I just want them to stay where they are. How could I go about this? I know how to run services and I can set up listeners, but the following has no effect:

    final IntentFilter bluetoothConnectedFilter = new IntentFilter( BluetoothDevice.ACTION_ACL_CONNECTED );
    bluetoothConnectedReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive( Context context, Intent intent ) {
             // Change volumes programmatically (code already tested and working elsewhere)
        }
    };

Thanks for any help.

  • Try to save the volume value in a variable and use that value when Bluetooth is connected or/and disconnected. Refer to this as it may help http://stackoverflow.com/questions/2924676/how-do-i-get-the-current-volume-amplitude-in-an-android-mediaplayer – Benyam Ephrem Mar 13 '15 at 04:23
  • Ok, now when I try to force a value on the system upon `BluetoothDevice.ACTION_ACL_CONNECTED` it still does not work. Based on tests I am led to believe this is because the action occurs before the volume change happens. I have tried using a Handler to delay the action by one second but get inconsistent results. Can someone help me do this in a way that is reliable? – ILoveAndroid Mar 13 '15 at 21:56
  • Are you forcing the volume change after Bluetooth is connected in your code? – Benyam Ephrem Mar 13 '15 at 23:48
  • The above code is where I'm doing it, in the onReceive method using: `audioManager.setStreamVolume( AudioManager.STREAM_MUSIC, musicVolume, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE );` – ILoveAndroid Mar 14 '15 at 13:18
  • What kind of variable is `musicVolume` and what does it store specifically?...Hmmm, maybe try to log the `musicVolume` to see what it is before and after connection... – Benyam Ephrem Mar 14 '15 at 13:35
  • `musicVolume` is an integer. The question must be, "How can I detect when the system changes my volume by virtue of Bluetooth connection?" If I understood that, I would have no problem at all. – ILoveAndroid Mar 15 '15 at 17:57
  • Maybe you can log a boolean method's result to answer that. Set up the method so it returns true when the current device's volume changes from its precious amount...maybe even add an `&&` and say that both volume have to change AND bluetooth must be connected or disconnected. I honestly don't know what else to say as I have never worked with Bluetooth before in an app. And, didn't you say that Bluetooth changed the volume when it connected or disconnected? Isn't that when the system changes the volume? – Benyam Ephrem Mar 15 '15 at 18:04

0 Answers0