How do I override onVolumeChanged from VolumeListener

Put your problem here if it does not fit any of the other categories.

How do I override onVolumeChanged from VolumeListener

Postby sbfalbo » Thu Dec 27, 2007 4:08 pm

I'm trying to override the default functionality on the onVolumeChanged method that gets called when the user increases or decreases the volume. I can't seem to find a way to access the VolumeListener so that I can override this method. Has anyone had any experience doing this? Thank you!
sbfalbo
Freshman
Freshman
 
Posts: 8
Joined: Wed Dec 26, 2007 7:17 pm

Top

Postby plusminus » Fri Dec 28, 2007 4:38 pm

Hello sfalbo,

you are probably talking about the VolumePanel-Class, right :?:
Tha Android-JavaDoc says:

public class
android.view.VolumePanel
java.lang.Object
android.view.VolumePanel

Handle the volume up and down keys. This code really should be moved elsewhere.

:D

Example-Code could be sth. like this, but the Class definitely needs to be changed/put somewhere else :!: because the sense already is somewhere else :lol:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 VolumePanel vp = new VolumePanel(this, a, b, c){
  2.                         @Override
  3.                         protected void onVolumeChanged(int index, int volume, int flags){
  4.                                
  5.                         }
  6.                 };
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby sbfalbo » Fri Dec 28, 2007 6:08 pm

Thanks plusminus,
Yes, I am referring to the VolumePanel class. I'm sure it has already been moved from the VolumePanel class for the next release but I will just use that in my code for now. Thank you for your help and I really enjoy your site. It is more useful than the Android Google Group!
sbfalbo
Freshman
Freshman
 
Posts: 8
Joined: Wed Dec 26, 2007 7:17 pm

Postby plusminus » Fri Dec 28, 2007 6:11 pm

:D (more than words...)
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby sbfalbo » Mon Dec 31, 2007 10:39 pm

Whenever I try to instantiate a VolumePanel object, I get an Array Index Out of Bounds Exception in the VolumePanel class. Has anyone worked with this object successfully?
sbfalbo
Freshman
Freshman
 
Posts: 8
Joined: Wed Dec 26, 2007 7:17 pm

how to have onVolumeChange() to be called?

Postby Quency » Mon Jan 28, 2008 8:20 pm

hi plusminus,

thanks for your direction about using onVolumeChanged().
I override the method and set a breakpoint inside. when either volume key up or down is pressed, the running does not stop at the breakpoint. Look like the method onVolumeChanged() is not triggered or called

Do I miss something? also I am not sure how to use the constructor
VolumePanel(Context context, int type, int[] volumes, String setting);
what value I should put for the parameters "type" and "setting"?


Below is my code which is put in OnCreate() method.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.        int type = 0;
  2.        int[]  volumes = new int[100];
  3.        VolumePanel mVolumePanel = new VolumePanel(this, type, volumes, Settings.System.RINGER_VOLUME){
  4.            @Override
  5.            protected void onVolumeChanged(int index, int volume, int flags){
  6.                    Log.i("wwwwww", "index="+index+" ;colume="+volume+" ;flags="+flags);
  7.                
  8.            }
  9.        };
Parsed in 0.032 seconds, using GeSHi 1.0.8.4




many thanks for your help in advance
-quency



plusminus wrote:Hello sfalbo,

you are probably talking about the VolumePanel-Class, right :?:
Tha Android-JavaDoc says:

public class
android.view.VolumePanel
java.lang.Object
android.view.VolumePanel

Handle the volume up and down keys. This code really should be moved elsewhere.

:D

Example-Code could be sth. like this, but the Class definitely needs to be changed/put somewhere else :!: because the sense already is somewhere else :lol:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 VolumePanel vp = new VolumePanel(this, a, b, c){
  2.                         @Override
  3.                         protected void onVolumeChanged(int index, int volume, int flags){
  4.                                
  5.                         }
  6.                 };
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Quency
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Jan 28, 2008 7:34 pm

Top

Postby sbfalbo » Tue Jan 29, 2008 12:31 am

Hi Quency,
I was never able to override this method either using the VolumePanel. I'm hoping that the next version of the SDK fixes this issue. If I do figure out a way around this, I will post it here too.
sbfalbo
Freshman
Freshman
 
Posts: 8
Joined: Wed Dec 26, 2007 7:17 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 25 guests