Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

J2ME: How to press keypad programmatically?

Is it possible to press keypad programmatically so that number for the key pressed shows on the screen? See the screenshot below for more explanation please:

alt text

Details:
Nokia N70
CLDC 1.1
MIDP 2.0

like image 993
Sarfraz Avatar asked Aug 19 '26 04:08

Sarfraz


2 Answers

How you approach it will depend on what you want to achieve.

You can quite easily simulate pressing keys on a Canvas, by calling your Canvas's keyPressed(), keyReleased() and keyRepeated() methods directly.

This could be good for testing a canvas-based game, ensuring a given state is entered when certain keys are pressed on the canvas.

However, this won't allow you to control any form-based interaction, or native prompts. So you can't start the MIDlet, navigate through a LCDUI Form or List, accept a native security prompt, or edit a native TextBox. You'd need to use an emulator and some form of test scripting framework which simulates keypresses, such as Eggplant.

like image 188
funkybro Avatar answered Aug 20 '26 19:08

funkybro


if you want to mimicking the keypressed process, just call the keypressed with the int of key as argument, for example keyPressed(-8);

Or are you trying to display the key number in the screen ?

like image 32
Ari R. Fikri Avatar answered Aug 20 '26 18:08

Ari R. Fikri