KeyCodeEvent
you are referring to EventInjector?
Try like this:
EventInjector.KeyCodeEvent = pressEsc
new EventInjector.KeyCodeEvent (EventInjector.KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_END,
KeypadListener.STATUS_NOT_FROM_KEYPAD, 3000);
Tags: BlackBerry Developers
Similar Questions
-
Call KeyCodeEvent - working character, but the numbers don't?
I invoke the keys in my application, but for some reason that I can't integers to translate into keys.
Here's what I do - starting a thread. The first inject it keys 'lol' and the second is supposed to do '123'
EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_DOWN, 'l' ,0)); EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_UP, 'l' ,0)); EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_DOWN, 'o' ,0)); EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_UP, 'o' ,0)); EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_DOWN, 'l' ,0)); EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_UP, 'l' ,0));
EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_DOWN, '1' ,0)); EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_UP, '1' ,0)); EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_DOWN, '2' ,0)); EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_UP, '2' ,0)); EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_DOWN, '3' ,0)); EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_UP, '3' ,0));
Actual letters work perfectly - the numbers never work well. I tried to inject (Char) 1 (tank) 2 (char) 3 as well, but that didn't work either.
Don't know about you, but my understanding is that key injection injects a key, and the pressure of the '1' key, to get generally have shift down. So I think you need to specify something like Keypad.STATUS_SHIFT as the last parameter of your KeyCodeEvent. See the documentation for more information.
-
What is the name of the button "mute" (for KeyCodeEvent)
I try to use EventInjector.KeyCodeEvent to simulate a button press "mute", but I can't find the keyName for her?
No one knows what is the name of the button mute? Or what I'm trying to do is put in standby mode, the unit is an easier way to do this?
Thanks in advance for your suggestions!
The desired key code is Keypad.KEY_SPEAKERPHONE. It is marked in the API as the "speaker" button, but in fact, it mutes and restores the sound of the phone. You can simulate with EventInjector by getting the key part of the code of the key and cast on a float:
(char) Keypad.key(Keypad.KEY_SPEAKERPHONE)
-
Key events of injection, but couldn't find what corresponds to the BB button?
I'm trying to inject a key event to simulate the user after pressing the Menu button - IE the one with the logo of BB, which is triggered by pressing Insert on the Simulator. I tried to use Keypad.KEY_APPLICATION (0x15), Keypad.KEY_MIDDLE (0 x 13), Keypad.KEY_MENU (0 x 1002) and there is no result to inject these keys at all. All the other keys I try to inject seems to work very well. There is another constant, should I use?
Using the JDE 4.3.0.1r version and the 8120 Simulator, if that makes a difference.
Nevermind, I got it works using a KeyCodeEvent instead of a KeyEvent...
-
Best practices for the application in the background
Hello
I would like to put an application in the background. Right now, I'm this problem by generating a key event «END».
However, with this method I have to request a change of permissions. Is there a better way to do this without requiring a change in permissions application?
KeyCodeEvent keyEnd = new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_END, 0); keyEnd.post();
Thank you
Thanks for the reply.
. popScreen() is not the case, but I found that UiApplication.requestBackground () will do.
Thank you
-
Hi all
How answering a call to auto or end a call?
Thanks in advance
ApplicationPermissions permissions = ApplicationPermissionsManager.getInstance().getApplicationPermissions();if (permissions.getPermission(ApplicationPermissions.PERMISSION_EVENT_INJECTOR) == ApplicationPermissions.VALUE_ALLOW) { EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_END, KeypadListener.STATUS_NOT_FROM_KEYPAD, 100);EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_UP, (char) Keypad.KEY_END, KeypadListener.STATUS_NOT_FROM_KEYPAD, 100);EventInjector.invokeEvent(pressEndKey);EventInjector.invokeEvent(releaseEndKey); success = true;}
-
Sailing with the Injection of the event guests
I try to use the event at some point injection back a prompt for the user. Now, however, just trying to get so that when the user clicks on my application of simple test on the home screen, the cursor goes up a line. I use the injector of the event and I can't seem to make it work. I have this simple method:
private void pressKey(char key) { EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN, key, KeypadListener.STATUS_NOT_FROM_KEYPAD)); EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_UP, key, KeypadListener.STATUS_NOT_FROM_KEYPAD)); }
When I call this method with the key "Characters.ESCAPE" it works and have the back screen of a user. However, when I call the method with the key "Characters.CONTROL_UP" it does not seem to do anything.
Inject an EventInjector.NavigationEvent instead of an EventInjector.KeyCodeEvent if you want to move up an icon on the home screen.
-
Disconnect the call triggered by the user
I need an application that must hang up initiated by the user and call another number (say a few default) programmatically.
I tried the following code in the method callInitiated() of the earpiece of the phone. But it does not work as expected.
Test 1 - using the method Phone.initiateCall)
public void callInitiated(int callid) { System.err.println("Call initiated.."+callid); try { Phone.initiateCall(callid, "1234888888"); } catch (RadioException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }
Test 2 - using the injector event method
public void callInitiated(int callid) { System.err.println("Call initiated.."+callid); PhoneCall phNr = Phone.getCall(callid); ApplicationPermissionsManager permissionsManager = ApplicationPermissionsManager.getInstance(); System.err.println("Beforeeeeee"+permissionsManager.getPermission ( ApplicationPermissions.PERMISSION_INPUT_SIMULATION)); if(permissionsManager.getPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION) != ApplicationPermissions.VALUE_ALLOW){ System.err.println("Permissions are NOT OK"); ApplicationPermissions neededPermissions = new ApplicationPermissions(); neededPermissions.addPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION); permissionsManager.invokePermissionsRequest(neededPermissions); System.err.println("Nowwwww the permission is....."+permissionsManager.getPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION)); } System.err.println("Permissions are OK"); EventInjector.KeyCodeEvent ev = new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN, Keypad.map(Keypad.KEY_END), KeypadListener.STATUS_ALT); System.err.println("b4 1 EventInjector invokeddddddddddddd"); EventInjector.invokeEvent(ev); System.err.println("aftr 1 EventInjector invokeddddddddddddd"); try { Thread.sleep(1000); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } EventInjector.KeyCodeEvent ev1 = new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_UP, Keypad.map(Keypad.KEY_END), KeypadListener.STATUS_ALT); System.err.println("b4 2 EventInjector invokeddddddddddddd"); EventInjector.invokeEvent(ev1); System.err.println("aftr 2 EventInjector invokeddddddddddddd"); }
The trials were unsuccessful, and no exception is thrown. Rather, the user dialed number is called.
What is the error that I do?
I use STATUS_NOT_FROM_KEYPAD, not STATUS_ALT.
I inject a keydown and keyup event. -
Unable to close an application developed
Hello
I developed an application that makes repeated voice calls every 10 seconds. Here's the code-
Import mypackage. MyScreen;
Import net.rim.blackberry.api.phone.Phone;
Import net.rim.device.api.system.RadioException;
Import net.rim.device.api.ui.UiApplication;
Import net.rim.device.api.system.EventInjector;
Import net.rim.device.api.system.EventInjector.KeyCodeEvent;
Import net.rim.device.api.system.KeypadListener;
Import net.rim.device.api.ui.Keypad;
Import net.rim.device.api.ui.component.Dialog;/**
* This class extend the UiApplication class, providing a
* graphical user interface.
*/
SerializableAttribute public class Voicecall extends UiApplication
{
/**
* Entry point for application
@param args command-line arguments (not used)
*/
Public Shared Sub main (String [] args)
{
Create a new instance of the application and make the currently
who runs the thread of the application of the event dispatch thread.
PAP Voicecall = new Voicecall();
theApp.enterEventDispatcher ();
}/**
* Creates a new object Voicecall
*/
public Voicecall()
{
running boolean = true;Push a screen onto the stack in the user interface for rendering.
pushScreen (new MyScreen());While (true) {}
try {}
Phone.initiateCall (Phone.getLineIds () [0], '45671234');
} catch (RadioException e) {}
Generative TODO catch block
e.printStackTrace ();
}try {}
Thread.Sleep (30000);
} catch (InterruptedException e) {}
Generative TODO catch block
e.printStackTrace ();
}final EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent)
KeyCodeEvent.KEY_DOWN, Keypad.KEY_END, KeypadListener.STATUS_NOT_FROM_KEYPAD (char));
EventInjector.invokeEvent (pressEndKey);
try {}
Thread.Sleep (10000);
} catch (InterruptedException e) {}
Generative TODO catch block
e.printStackTrace ();
}
}
}
}I'm not able to close this application once I start it
I am a beginner so please forgive my igonarance
See you soon
Rajat
I have a created a thread to introduce voice calls, and now I can see the option close
Thank you
-
KeyInjection (Trackpad)
Hello
I'm trying to inject the right key with the key injection, but it does not work:
EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN,Characters.CONTROL_RIGHT, KeypadListener.STATUS_NOT_FROM_KEYPAD, 100); EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_UP,Characters.CONTROL_RIGHT, KeypadListener.STATUS_NOT_FROM_KEYPAD, 100); EventInjector.invokeEvent(pressEndKey); EventInjector.invokeEvent(releaseEndKey);
Does anyone know how to properly inject the right key?
Thank you!
If anyone needs the following code:
EventInjector.NavigationEvent press = new EventInjector.NavigationEvent(EventInjector.NavigationEvent.NAVIGATION_MOVEMENT ,1,0,KeypadListener.STATUS_NOT_FROM_KEYPAD ); EventInjector.invokeEvent(press);
-
Anyone know how to get the uptime? start a startup apps is not really an option, I'm sure there is a way without that, because application as my bb fighting shows uptime as soon as you install it (without having to restart the device).
I know I have read both of the function ' protected boolean navigationClick (int status, int time) {"but then I have to click to view uptime.
I want to make is that I have an apps that will connect almost everything what is happening with your phone list app, temperature, level, etc. It run in the background and fill every batterystate changes, so I can't really use the navigationclick (unless I found a way to simulate a navigationclick batterystate change each time).
Thank you
Well, sometimes it is the easy thing is the hardest thing to find, anyway here's how you can get uptime when you want. I don't understand why it took so long to figure out. p
public int getUptime() {}
EventInjector.KeyCodeEvent keyCodeEvent = new EventInjector.KeyCodeEvent (KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_NEXT, 0, 100);
Return keyCodeEvent.getTime ();
}you create an event, but you don't do anything with it, you just read time and it will return the number of milliseconds since the last battery pull
-
How to click on the MENU button
Hello
I use Simulator 9550 and BlackBerry JDE 5.0.
in my application, I try to click on the menu with the following code key.
EventInjector.invokeEvent (new EventInjector.KeyCodeEvent (EventInjector.KeyCodeEvent.KEY_DOWN, Keypad.map ((char) Keypad.KEY_MENU), KeypadListener.STATUS_NOT_FROM_KEYPAD));
EventInjector.invokeEvent (new EventInjector.KeyCodeEvent (EventInjector.KeyCodeEvent.KEY_UP, Keypad.map ((char) Keypad.KEY_MENU), KeypadListener.STATUS_NOT_FROM_KEYPAD));But I found it click on the phone instead, key
Solved this problem by changing to '(char) Keypad.KEY_MENU'.
-
Hello
Is there another way to reject a call by programming using injection of strike?
Rgds,
Siva
Try this code.
class IncomingCallListener2 extends AbstractPhoneListener { int callId; PhoneCall phoneCall; String incomingCallPhoneNumber; public static final long NOTIFICATIONS_ID_1 = 0xdc5bf2f81374095L; IncomingCallListener2() { Phone.addPhoneListener(this); } public void callIncoming(int callId) { phoneCall = Phone.getCall(callId); incomingCallPhoneNumber = phoneCall.getDisplayPhoneNumber(); //incomingCallPhoneNumber = incomingCallPhoneNumber.substring(7); NotificationsManager.registerSource(NOTIFICATIONS_ID_1, new Object() { public String toString() { return "Profile 1"; } } ,NotificationsConstants.FORCED); System.out.println("After Firing event1"); NotificationsManager.registerConsequence(ConsequenceImpl.ID, new ConsequenceImpl()); System.out.println("After Firing event 2"); NotificationsManager.triggerImmediateEvent(NOTIFICATIONS_ID_1, 0, this, null); System.out.println("After Firing event 3"); } //Event e = new Event(0xbd2350c0dfda2a51L, ++_eventIdGenerator, 500, -1, NotificationsConstants.OUT_OF_HOLSTER_TRIGGER); //e.fire(); */ } } private static final class ConsequenceImpl implements Consequence, SyncConverter { public static final long ID = 0xbd2350c0dfda2a51L; //net.rim.samples.device.notificationsdemo.NotificationsDemo.ConsequenceImpl private static final int TYPE = 'n' << 24 | 'o' << 16 | 't' << 8 | 'd'; //notd for NotificationsDemo private static final byte[] DATA = new byte[] {'m', 'y', '-', 'c', 'o', 'n', 'f', 'i', 'g', '-', 'o', 'b', 'j', 'e', 'c', 't'}; private static final Configuration CONFIG = new Configuration(DATA); Player p = null; private static final int VOLUME = 80; //% volume /** * A static inner class, describing the Configuration information for this consequence *
This implementst the SyncObject interface, although returns a fixed value. */ private static final class Configuration implements SyncObject, Persistable { public byte[] _data; public Configuration(byte[] data) { _data = data; } public int getUID() { return 0; //we're not actually doing any synchronization (vs backup/restore) so we don't care about this value } } public void startNotification(long consequenceID, long sourceID, long eventID, Object configuration, Object context) { EventInjector.KeyCodeEvent ev = new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN, ((char)Keypad.KEY_END), KeypadListener.STATUS_ALT,5000); EventInjector.invokeEvent(ev); } public void stopNotification(long consequenceID, long sourceID, long eventID, Object configuration, Object context) { } /** * It is likely that the following call will return a separate config object for each SourceID, such as data * that describes user set notification settings. However, for this example, we a trivial, arbitrary conifg object */ public Object newConfiguration(long consequenceID, long sourceID, byte profileIndex, int level, Object context) { System.out.println("in newconfiguration method()"); return CONFIG; } /** * Called when there is inbound (from the desktop) data to be converted to object form */ public SyncObject convert(DataBuffer data, int version, int UID) { //it's up to us to write and read the data. we apply a four byte type and a 4 byte length, and then the raw data try { int type = data.readInt(); int length = data.readCompressedInt(); if ( type == TYPE ) { byte[] rawdata = new byte[length]; data.readFully(rawdata); return new Configuration(rawdata); } } catch (EOFException e) { //we've prematurely reached the end of the DataBuffer System.err.println(e); } return null; } public boolean convert(SyncObject object, DataBuffer buffer, int version) { boolean retval = false; if ( object instanceof Configuration ) { Configuration c = (Configuration)object; buffer.writeInt(TYPE); buffer.writeCompressedInt(c._data.length); buffer.write(c._data); retval = true; } return retval; } }
-
Launch application on KeyPress sequence - Code example included
I searched this forum and google hours and could not get it to work.
I used this thread:
http://supportforums.BlackBerry.com/T5/Java-development/launch-application-on-12345/m-p/502771
I have a background process which is a PhoneListener.
It intercepts the void callInitiated(int callid) and checks the sequence.
If the sequence is the right one, she injects an end key and starts the application.
There are 2 problems:
(1) the dialed number appears with? prefix and I can't seem to find the right channel for the game.
(2) if I inject end, the call ended, but so is my application that I just launched.
I tried waiting and I tried the function calls but no dice the reorganization.
public void callInitiated(int callid) { String dialedNumber = Phone.getCall(callid).getDisplayPhoneNumber(); System.out.println("!!!!!!!!!!!! Dialed:" + dialedNumber.length()); if (true || dialedNumber.endsWith(KEY_SEQUENCE)) { // end the call // EventInjector.KeyCodeEvent ev = new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN, ((char)Keypad.KEY_END), KeypadListener.STATUS_NOT_FROM_KEYPAD); // EventInjector.invokeEvent(ev); final UiApplication app = UiApplication.getUiApplication(); app.invokeLater(new Runnable() { public void run() { try { Thread.sleep(20); } catch (InterruptedException e) { e.printStackTrace(); } try { ApplicationManager.getApplicationManager().launch( "MyApp?gui"); } catch (ApplicationManagerException e) { e.printStackTrace(); } } }); } }
any help?
Thank you
He solved.
for some reason, the callInitiated (.) is called several times for each call
Make sure that your code to initiate and end the call is executed only once (I used a hashtable and stored the callid) and you're golden.
-
Hello
I'm doing an injection of striking during a phone conversation, I added an element of system menu (PHONE did not work for some reason, the menu never appeared) and the menu item appears. What I'm trying to do, it's when the menu item get clicked he should call the menu again and put the call on hold, so it would press the menu button, navigate to the dock and click. I write code just to call the menu (I removed the pieces to navigate and click to try to simplify):
[CODE] net.rim.blackberry.api.menuitem import. *;
Net.rim.device.api.system import. *;
Net.rim.device.api.ui import. *;class TestMenu extends ApplicationMenuItem {}
TestMenu (order int) {}
Super (Order);
}
public Object execute (Object o)
{
New Thread() {}
public void run() {}
EventInjector.KeyCodeEvent MENUAppuyez = new EventInjector.KeyCodeEvent (EventInjector.KeyCodeEvent.KEY_DOWN,
Characters.CONTROL_MENU, KeypadListener.STATUS_NOT_FROM_KEYPAD, 100);
EventInjector.KeyCodeEvent menuRelease = new EventInjector.KeyCodeEvent (EventInjector.KeyCodeEvent.KEY_UP,
Characters.CONTROL_MENU, KeypadListener.STATUS_NOT_FROM_KEYPAD, 100);
try {}
Thread.Sleep (3000);
} catch (Exception e) {}
}
EventInjector.invokeEvent (menuPress);
try {}
Thread.Sleep (100);
} catch (Exception e) {}
}
EventInjector.invokeEvent (menuRelease);
}
}. start();Return to o;
}public String toString() {}
return "Test Item";
}
} [/ CODE]I try it on BlackBerry JDE 4.2.1 with 8800 Simulator, I changed the default permissions to allow Injection of typing (I could not find an entry for my app in the list of applications) and started the application. I made a call, went into the menu and click on Test point, nothing happens. If I debug him I can see that the run method is called so there is nothing wrong with my ApplicationMenuItem code, but there is something wrong with the injection of the hit.
Can someone help me here please?
Concerning
icefrost1
Sorry, never done anything like myself and not sure that I can help, but here are a few thoughts. I've read other forum entries that do these sorts of things, and it should work according to my knowledge of BB, but as stated, not actually tried myself.
When your ApplicationMenuItem is running, the menu actually, so you hit injection will be against this. From the menu, I believe, is effectively locked until complete the MenuItem, you're going to struggle to summon it again and it will ignore your keystrokes at the keyboard I think.
In order to let the full treatment, which must close the Menu and then run your piece of code. Running your code in a Runnable invokeLater() should do it for you. So replace this:
public Object execute (Object o)
{
New Thread() {}
public void run() {}...
}. start();
Return to o;
}with
public Object execute (Object o)
{
UiApplication.getUiApplication (new Runnable() {}
public void run() {}...
});
Return to o;
}I think it has more work than your original code change, but I think that there is a better way. In your ApplicationMenuItem code, if you d a UiApplication.getUiApplication () .getActiveScreen (), you should get the Menu screen. If you get the screen below (Screen.getScreenBelow ()), then this is the original screen, that has the Menu with the item that you want to call. Now you can get this Menu (Screen.getMenu), then browse the Menu items, looking for the Menu that you want to call. Once you have found, you can call it using its run() method. All this is done by your code without the user to actually see the key features.
Who will do the work?
OK got to ask. Why if the user clicks your menu item to put a call on hold, when they could just put on hold themselves?
Don't really want an answer, just had fun at this thought.
Maybe you are looking for
-
Reduce consumption of battery motion and automatic brightness
Hi, I would like to know some things. First: activation reduce motion put on iPhone save the battery life since perspective wallpapers are being turned off when the low power Mode is on? Second: Automatic Rotation of the brightness to the wide and ho
-
HP G61-429 WM: USB FOR laptop HP G61-429WM
Could you please tell me if I can use a Lexar 32 GB jumpdrive USB 3.0 on my laptop HP G61-424WM. Thank you
-
Arguments for command line for TestStand tools
If I run the user interface of the command-line like this: I get this: Now, I want to create a tool. Then in the sequence editor, I go to tools > customize... Then I add a command tool pointing to the executable of the user interface. Then, I try
-
Programmatically determine the version of LabVIEW for a VI/control
Hi all Given the path to control of VI / I want to get the version in which it is the last record. Is it possible to do? I do this to identify all of its dependencies - programmatically by adding to a project and getting his list of dependencies by u
-
Hotmail calendar error Whenever I try to open my hotmail calendar this message appears connection error There is a problem connecting to Hotmail calendar now. Please make sure that you are connected to the Internet and try again. For sure, I understa