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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Developer
Posts: 11
Registered: ‎11-11-2009
My Device: 8800
My Carrier: Airtel
Accepted Solution

Is there Api public api to check the slider is open or close for blackberry 6.0?

Hello All,

 

is there any api to check slider is open or close for Blackberry JDE 6.0.

 

Thanks,

Navneet Gupta.

Thanks,
Navneet Gupta.
Contributor
Posts: 14
Registered: ‎10-21-2010
My Device: 9520
My Carrier: no

Re: Is there Api public api to check the slider is open or close for blackberry 6.0?

Hi dear,

 

  First of all "accept the solution please..."

 

Show this link for more .....

 

 

http://www.blackberry.com/developers/docs/4.6.0api/net/rim/device/api/system/Sensor.html

 

 

 

import net.rim.device.api.system.*;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;

public class SensorDemo extends UiApplication
{
    public SensorDemo()
    {
        SensorDemoScreen screen = new SensorDemoScreen();
        pushScreen(screen);
    }
    public static void main(String[] args)
    {
        SensorDemo app = new SensorDemo();
        app.enterEventDispatcher();
    }
    class SensorDemoScreen extends MainScreen implements SensorListener
    {
        private RichTextField statusField1;
        private RichTextField statusField2;

        public SensorDemoScreen()
        {
            setTitle("Sensor Demo");
            statusField1 = new RichTextField();
            statusField2 = new RichTextField();
            add(statusField1);
            add(statusField2);

            // Check for the presence of a sensor
            boolean hasFlipSensor, hasHolsterSensor, hasSliderSensor;
            hasFlipSensor = Sensor.isSupported(Sensor.FLIP);
            hasHolsterSensor = Sensor.isSupported(Sensor.HOLSTER);
            hasSliderSensor = Sensor.isSupported(Sensor.SLIDE);
            statusField1.setText("Flip: " + hasFlipSensor + "\nHolster: "
                    + hasHolsterSensor + "\nSlider: " + hasSliderSensor + "\n");
            // Check for the state of a sensor
            if (Sensor.isSupported(Sensor.SLIDE))
            {
                int sliderState = Sensor.getState(Sensor.SLIDE);
                switch (sliderState)
                {
                    case Sensor.STATE_SLIDE_CLOSED:
                        // do something if slider is closed
                        statusField2.setText("Slider is closed.");
                        break;
                    case Sensor.STATE_SLIDE_IN_TRANSITION:
                        // do something if slider in transition
                        statusField2.setText("Slider is between open and closed.");
                        break;
                    case Sensor.STATE_SLIDE_OPEN:
                        // do something if slider is open
                        statusField2.setText("Slider is open.");
                        break;
                    default:
                        statusField2.setText("Can't determine state of slider.");
                }
            }
            // Listen for changes to a sensor
            Sensor.addListener(Application.getApplication(), this,
                    Sensor.SLIDE);
        }

        // implementation of SensorListener.onSensorUpdate()
        // only checks for slider changes
        public void onSensorUpdate(int sensorID, int update)
        {
            if (sensorID == Sensor.SLIDE)
            {
                if (update == Sensor.STATE_SLIDE_OPEN)
                {
                    // do something if slider is now open
                    statusField2.setText("Slider is now open.");
                }
                else if (update == Sensor.STATE_SLIDE_IN_TRANSITION)
                {
                    // do something if slider is now transitioning
                    statusField2.setText("Slider state is changing.");
                }
                else if (update == Sensor.STATE_SLIDE_CLOSED)
                {
                    // do something if slider is now closed
                    statusField2.setText("Slider is now closed.");
                }
            }
        }
    }
}

.................

Manoj Kumar Baghela

New Developer
Posts: 11
Registered: ‎11-11-2009
My Device: 8800
My Carrier: Airtel

Re: Is there Api public api to check the slider is open or close for blackberry 6.0?

Hi Manoj,

 

Tried that sample code but in Senor class there is not final static constant for SLIDE.

Below is the errors i am getting when complied code provide by you.

 

symbol  : variable SLIDE
location: class net.rim.device.api.system.Sensor
            if (sensorID == Sensor.SLIDE)
                                  ^

symbol  : variable STATE_SLIDE_OPEN
location: class net.rim.device.api.system.Sensor
                if (update == Sensor.STATE_SLIDE_OPEN)
                                    ^

symbol  : variable STATE_SLIDE_IN_TRANSITION
location: class net.rim.device.api.system.Sensor
                else if (update == Sensor.STATE_SLIDE_IN_TRANSITION)
                                         ^

symbol  : variable STATE_SLIDE_CLOSED
location: class net.rim.device.api.system.Sensor
                else if (update == Sensor.STATE_SLIDE_CLOSED)
                                         ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

 

Please check and let me know

 

Thanks in Advance

Navneet Gupta.

Thanks,
Navneet Gupta.
Contributor
Posts: 14
Registered: ‎10-21-2010
My Device: 9520
My Carrier: no

Re: Is there Api public api to check the slider is open or close for blackberry 6.0?

ok , Please forword that problem, then I can manage.

Contributor
Posts: 21
Registered: ‎04-21-2011
My Device: Developer
My Carrier: ----

Re: Is there Api public api to check the slider is open or close for blackberry 6.0?

has thi sissue been solved can you please guide with its correct implementation?