Reputation: 1691
I have a small Java ME project (a game) that I'd like to port to BlackBerry, where I don't have any experience yet. I have identified 2 categories of devices that I would like to support, based on whether or not they support touch:
1. 320x240 and 480x360 (non-touch)
2. 360x480 (touch)
For the non-touch devices, the changes would be minimal (I will only re-map the keys to control the game), but with touch devices it seems tricky. I assume I will have to have 2 different code bases, since pre-4.7 devices didn't have touch API, and am looking for a way to minimize the amount of code I have to write. Ideally I would like to have only 1 project (is that possible)? Any suggestions on how to organize this project would be very appreciated. Thank you.
Upvotes: 0
Views: 218
Reputation: 8485
You're right, if you're trying to support pre-4.7 devices your app won't work if it's using the touch API. You can surround touch-specific code with something like
//#ifdef STORM
import net.rim.device.api.ui.TouchEvent;
//#endif
I use Netbeans. The "STORM" definition is the name of my NB configuration, but you can define your own, etc... Sorry to just paste links, but I don't know how to do it in Eclipse.:
And elsewhere on SO:
Using preprocessor directives in BlackBerry JDE plugin for eclipse?
Edit: I know this might seem like a NB specific answer, but the preprocessor is actually supported by the BlackBerry tools in general.
Upvotes: 0
Reputation: 837
It's not necessary to have two separate builds to support both Touch and Non-Touch devices. You can implement theTouchEvent
, NavigationMovement
, and KeyDown
methods in the appropriate classes to handle both interaction methods. The TouchEvent
method would handle all touchscreen related interaction and the NavigationMovement
and KeyDown
methods would provide interaction with the devices that have a keyboard and a trackpad.
The Blackberry Torch has both a touchscreen and a trackpad which would even further complicate the separate build method.
Upvotes: 2