Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

J2ME Soft Key Wrapper

Reading some articles, told me that soft keys varies between devices. Some says -6 or -21 for left soft key and -7 or -22 for right soft key. Given this situation, is there any good wrapper or function or best practice to handle it properly?

If not possible for ALL devices, what is the best way to support most devices? with minor or no hack at all?

like image 278
ariefbayu Avatar asked Nov 15 '09 01:11

ariefbayu


2 Answers

To give you a feel for the scope of the problem have a look at this table of keycodes.

Omermuhammed's approach is a good one if you are able to vary the JAD content depending on the target handset, for example by looking at the user-agent header field in a download request from an on-handset web browser.

If you cannot identify the handset until the app has been delivered, you could look at something like this that basically determines the host handset at run time and sets the keycode mappings appropriately. Looks cumbersome to me though.

Lastly, if your application uses a subset of codes you may be able to get away with hard-coded lists - for some codes there are no or few collisions (LEFT is usually either -3 or -61, and those codes usually don't mean something else). Again, not an ideal approach.

Final suggested resources for you: wurfl or user agent strings, and the J2MEPolish devices database for device keycodes.

like image 173
martin clayton Avatar answered Nov 03 '22 18:11

martin clayton


The easiest way I found was to set it up in code with the recommended values based on ITU-T standard and override it with a jad parameter. So, for any given app, it will look for existance of the jad parameter at app startup time and set it, otherwise it will use the default values.

I have used these and similar techniques to write apps that can be rapidly ported, and this process is generally well known.

like image 4
omermuhammed Avatar answered Nov 03 '22 18:11

omermuhammed