Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8011967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:10:53+00:00 2026-06-04T19:10:53+00:00

I am working on a Blackberry application which includes Zoom pinch functionality, but this

  • 0

I am working on a Blackberry application which includes Zoom pinch functionality, but this functionality works in touch screen devices. My app will work on curve type of devices too.

Please let me know if “I can detect programmatically if the device is touch screen or not” so I can make my application flexible for both types.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:10:55+00:00Added an answer on June 4, 2026 at 7:10 pm

    If you only need to support OS 4.7+ devices, then you don’t need to use the preprocessor. You can programmatically test for the touchscreen with this:

    boolean isTouch = TouchScreen.isSupported();
    

    What Rupak suggested in his answer may not be enough (just adding touch handling code, which will be ignored for non-touch devices). In your case, if you want to support a zoom feature, you may need to actively detect a non-touch device (with the code above), and choose to add a new zoom ButtonField, which is not even shown on touch devices that do support the pinch gesture. If you don’t do this, then either non-touch devices won’t be able to zoom, or touch devices will have their screens cluttered with an unnecessary button.

    But, the TouchScreen API is only for 4.7+. If you need to run the same code on older OS versions, too, this other method can be used:

    boolean isTouch = (new Canvas(){protected void paint(Graphics graphics){}}).hasPointerEvents();
    

    My apps mostly still do support 4.5+, which can’t even compile touch handling code. So, I normally rely on this kind of preprocessor macro to selectively compile different code. First, at the top of the file

    //#preprocess
    

    Then, anywhere inside the file:

    //#ifndef TOUCH_SCREEN
    /*
    //#endif
    
    // code only for touch devices:
    import net.rim.device.api.ui.TouchEvent;
    
    //#ifndef TOUCH_SCREEN
    */
    //#endif
    

    And then for builds that I will produce for deployment to touchscreen devices, I add the TOUCH_SCREEN preprocessor flag. If you don’t want to worry about uploading different app bundles for touch vs. non-touch devices, just programmatically detect touch screens with the Java code (isTouch) and use the preprocessor just to remove code that won’t compile on pre-4.7 OS versions.

    Note: this somewhat confusing “double negative” preprocessor logic is not a mistake. It’s like that to accommodate the slightly different way preprocessors in BlackBerry-enabled IDEs (e.g. JDE, Eclipse, Netbeans) handle preprocessing. Unfortunately, preprocessing is not a standardized J2ME feature, so it’s implementation is a little flaky.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a blackberry application which includes radio button controls. HorizontalFieldManager hr
I have a working application which gets the GPS Long/Lat of from a BlackBerry
I am designing a Netflix Application for BlackBerry mobile devices. I am currently working
Currently i am working on Blackberry Application and stuck at this point that how
i am working on porting an iphone application to blackberry devices. i could not
I am working on a BlackBerry Application which requires the application be running once
I'm working on a blackberry application which requires to pass a parameter to another
I have developed an application for blackberry devices. The application is working fine if
I have been working on a BlackBerry application that consumes web services from ColdFusion
I am working on BlackBerry user interface. But the BlackBerry UIs are less attractive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.