Perry_ml
Perry_ml

Reputation: 495

Get rid of different volumes for headphones and speaker

By default, android saves and sets different volumes for headphones and speaker. On andorid 2.1 it isn't happening, but I noticed it since android 2.3. I need to get rid of this behavior somehow. Any thoughts?

I'm developing a volume management application and this is messing with the volumes user sets in my app. Andorid 2.1 and up.

Upvotes: 1

Views: 1057

Answers (1)

Perry_ml
Perry_ml

Reputation: 495

Ok, since nobody answered, I will at least share what I end up doing to solve this.

I made two services (I already had those, just modified their behavior). One that registers broadcast receiver for Intent.ACTION_HEADSET_PLUG a and when unplugged broadcast arrives it sets volumes stored in application's shared preferences - so it overrides change of volume that android automatically did. Second service registers observer for change of settings, like this:

  getContentResolver().registerContentObserver( 
            android.provider.Settings.System.CONTENT_URI, true, observer);

Among other things, this observer stores current volume levels into application's shared preferences (used in first service). Plus it seems that this observer is not called when android is doing automatic change of volume described above, which is good.

Upvotes: 1

Related Questions