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
Developer
Posts: 484
Registered: ‎07-17-2008
My Device: Not Specified
Accepted Solution

Detect Touchscreen

I'm looking for a way to detect if the device has a touchscreen using JDE 4.5

 

Is there a system property I can use?

 

Thanks.

Developer
Posts: 85
Registered: ‎12-05-2008
My Device: Blackberry 8900 Javelin

Re: Detect Touchscreen

I thought touch arrived in 4.7 only.
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Detect Touchscreen

You can get the OS level and if it is 4.7.0.0 or greater, you have a touch screen.  Smiley Happy

 

Of course, not sure what you do with this info if you are executing in a 4.5 environment, since you cannot actually take advantage of the touch screen on this level.

 

 

 

 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Detect Touchscreen

Having just been there myself, you can make use of this when trying to use a single code base, to, for example, make your ListFields more fat finger friendly by increasing the rowHeight. 
Developer
Posts: 484
Registered: ‎07-17-2008
My Device: Not Specified

Re: Detect Touchscreen


RexDoug wrote:

You can get the OS level and if it is 4.7.0.0 or greater, you have a touch screen.  Smiley Happy

 

Of course, not sure what you do with this info if you are executing in a 4.5 environment, since you cannot actually take advantage of the touch screen on this level.


 

Yeah, but what if it's OS 5.0 running on the Bold for example.


I wanted to detect the touchscreen and use it to exclude an option but maybe I should take a different approach.

 

Is there a way to detect if the device has a trackball instead?

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

Re: Detect Touchscreen

Let me amend my post to say "OS Level 4.7.*.*"

 

AFAIK, ther is no other touch screen OS level beside 4.7.

 

We still support devices with trackwheel, and we do this by looking at the device model using DeviceInfo.getDeviceName()

 

So, you could accomplish what you want by retrieving the device model.

 

Something like this:

 

public boolean hasTouchScreen() { if (DeviceInfo.getDeviceName().startsWith("95")){ return true; } else { return false; } }

 

 

Developer
Posts: 484
Registered: ‎07-17-2008
My Device: Not Specified

Re: Detect Touchscreen


peter_strange wrote:
Having just been there myself, you can make use of this when trying to use a single code base, to, for example, make your ListFields more fat finger friendly by increasing the rowHeight. 

What approach did you end up using or are you still working on it?

Developer
Posts: 484
Registered: ‎07-17-2008
My Device: Not Specified

Re: Detect Touchscreen


RexDoug wrote:

we do this by looking at the device model using DeviceInfo.getDeviceName()

 

So, you could accomplish what you want by retrieving the device model.

 


I thought about this, and it may be the best solution, but you just don't know what the next touchscreen device model is going to be. Or do you?  :-)
Too bad the DeviceInfo class doesn't have a hasTrackball() method.
 

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Detect Touchscreen

@jonberry - re "What approach did you end up using or are you still working on it?" I presume you asking about how we detect?  We currently do the model thing as suggested elsewhere to set the default, but am thinking we will add this as an option so that people can set it if we have chosen incorrectly.

 

Re new Touchscreen device, I've asked for a Wi-Fi Storm, but was told not to hold my breath.....

Highlighted
Developer
Posts: 72
Registered: ‎03-14-2009
My Device: Not Specified

Re: Detect Touchscreen

Hi,

 

in my games I use Canvas.hasPointerEvents() and I had no problems to support the Storm touchdisplay with a game compiled using the 4.2 Component Pack.

 

Sure - my game is a MIDlet, but I'd give it a try and just create a Canvas instance and use hasPointerEvents to detect a touchdisplay in non MIDlet app too.

 

Michael