Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
Posts: 2
Registered: ‎03-23-2010
My Device: Storm 9550
My Carrier: Verizon

Change the Active Sound Profile

Hello, I'm new in the forum and this is my first question.

Is there any way to change the active sound profile programmatically? I would like to be able to select from the existing sound profiles and change the active one.

Thank you

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Change the Active Sound Profile

 

There is no API for selecting the current profile. Some folks have accomplished this using key event injection.

 

This question is commonly asked and answered on the forum. If you search you will find many threads on the subject.

 

 

 

 

 

 

 

Highlighted
New Developer
Posts: 28
Registered: ‎11-04-2009
My Device: Not Specified

Re: Change the Active Sound Profile

Could you give us a clue about it?

You say that there are threads talking about event injection to change the sound profile?

I could not find them.

 

Thanks in advance.

I tried to change the world, but I couldn't find the source code
New Developer
Posts: 28
Registered: ‎11-04-2009
My Device: Not Specified

Re: Change the Active Sound Profile

I've done a sample that does what I needed.

 

But it isn't usefull to me, because I need this routine to run in background. And if the keyboard is locked, the event injection doesn't work.

 

 

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.notification.*;
import net.rim.device.api.ui.*;
class MainApp extends UiApplication 
{
    public static void main(String[] args)
    {
        MainApp instance = new MainApp();
        instance.enterEventDispatcher();
    }  
    public MainApp() 
    {
        pushScreen(new AppScreen());
    }
    class AppScreen extends MainScreen
    {
        
        private void selectProfile( final int index ) {
    
            ApplicationManager manager = ApplicationManager.getApplicationManager();
            try {
                manager.launch( "net_rim_bb_profiles_app" );
            
                Thread th = new Thread( new Runnable() {
                    public void run() {
                        try { Thread.sleep( 250 ); } catch( Exception ex ) { }                    
                        move( -1000 );                                        
                        for (int i = 0; i < index; i++) {
                            moveDown(  );                    
                        }
                        pressKey( (char) Keypad.KEY_ENTER );
                    
                    }
                } );
                th.start();
            }
            catch( Exception ex ) {
                Dialog.alert( ex.toString() );
            } 
    
        }
    
        public AppScreen()
        {
            super();
            for ( int i = 0; i < 6; i++ ) {
                final int idx = i;
                add( new ButtonField( "Select sound profile " + i ) {
                    protected  boolean trackwheelClick(int status, int time) {
                        selectProfile( idx );
                        return true;
                    }
                } );
            }
        }
        private void pressKey( char key ) {
            EventInjector.KeyCodeEvent pressKey = new EventInjector.KeyCodeEvent(  
                EventInjector.KeyCodeEvent.KEY_DOWN, key, 0, 100);  
            
            EventInjector.KeyCodeEvent releaseKey = new EventInjector.KeyCodeEvent(  
                EventInjector.KeyCodeEvent.KEY_UP, key, 0, 100);  
            
            EventInjector.invokeEvent(pressKey);  
            EventInjector.invokeEvent(releaseKey);  
            pressKey.post();
            releaseKey.post();        
        
        }
        private void moveDown(  ) {
            move( 1 );
        }
        private void moveUp(  ) {
    
            move( -1 );
            
        }
        private void move( int amount ) {
    
            EventInjector.NavigationEvent evt = new EventInjector.NavigationEvent(
                EventInjector.NavigationEvent.NAVIGATION_MOVEMENT
                0, 
                amount, 
                KeypadListener.STATUS_TRACKWHEEL 
            ); 
            evt.post();
        }
       
        public boolean onClose()
        {
            System.exit(0);
            return true;
        }
    }
}

 

I tried to change the world, but I couldn't find the source code
Developer
Posts: 86
Registered: ‎10-28-2010
My Device: Blackberry Curve, Bold and Strom
My Carrier: Vodafone

Re: Change the Active Sound Profile

 

This code is working Fine. Only it's not showing the profile name on the button. I also want to fetch the profile name as well ..

 

 

 If someone having any idea please let me know

 

Thanks

Neeraj chauhan

Thanks & Regards
Neeraj Chauhan