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
myraddin
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810
Accepted Solution

How to use EventInjector to inject ESC

Hi all.

 

I am trying to remove those (in my case) 'nag' dialogs that pop up in case of call failing, etc.

 

I tried two approaches:

 

 

EventInjector.invokeEvent(new

EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN,
Characters.ESCAPE, 0));

and

 

KeyCodeEvent eEscDown = new KeyCodeEvent(KeyCodeEvent.KEY_DOWN,
Characters.ESCAPE,

KeypadListener.STATUS_ALT);
KeyCodeEvent eEscUp = new KeyCodeEvent(KeyCodeEvent.KEY_UP,
Characters.ESCAPE,

KeypadListener.STATUS_ALT);

eEscDown.post();
eEscUp.post();

 

which both work fine on the simulator  (2.9.0.52) but in the application I get a strange error:

 

EventInjector$KeyEvent$.<init> nout found

 

 

Basicall, I just want to end the popup screen (I suppose it's an alert screen I cannot intercept in any other way, right?).

 

 


 



"Listen carefully, I shall say this only once"
Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: How to use EventInjector to inject ESC

Hi,

Please check the settings on device. Options => Advanced Options => Applications => ABC(Your Application) =>Edit DEfault permissions =>Interactions =>key stroke Injection. Check is this allow or deny.

 

Tnx.


Use Search. "Accept Solution" If the problem is resolved.
Developer
myraddin
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: How to use EventInjector to inject ESC

Sorry I forgot to mention.

 

Everything is set to Allow.

 

Device: bb 8110 v4.3.0.93



"Listen carefully, I shall say this only once"
Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: How to use EventInjector to inject ESC

Hi,

Following is working for my case...

UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { EventInjector.KeyEvent inject = new EventInjector.KeyEvent (EventInjector.KeyEvent.KEY_DOWN,Characters.ESCAPE, 0, 50); inject.post(); inject.post(); } });

 

Tnx.

 

Use Search. "Accept Solution" If the problem is resolved.
Developer
myraddin
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: How to use EventInjector to inject ESC

Yes. you are right. The Device doesn't complain about your code.

 

Why are you posting twice ?

 

And how come doesn't this work:  (I guess it will stay a mistery)

 

 

EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(

EventInjector.KeyCodeEvent.KEY_DOWN,
Characters.ESCAPE, 0));

 

Thanks.

 

 



"Listen carefully, I shall say this only once"
New Developer
BBnu
Posts: 3
Registered: ‎05-12-2009
My Device: Not Specified

Re: How to use EventInjector to inject ESC

Not sure about the double post, but you probably needed to call it on the UI event loop (I assume it has some UI :smileyhappy:) - hence the invoke..
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to use EventInjector to inject ESC

"how come doesn't this work"

 

EventInjector.invokeEvent(new EventInjector.KeyCodeEvent(

                            EventInjector.KeyCodeEvent.KEY_DOWN,
                            Characters.ESCAPE, 0));

 

I suspect this is becuase constructor was only introduced in 4.5.  I'm betting you are using a 4.5 or later JDE, but you are running on a 4.3 device, which does not know about that specific constructor. 

 

You should always use a JDE level that is earlier or the same as your target device.

New Developer
learningbb
Posts: 45
Registered: ‎06-05-2009
My Device: Not Specified

Re: How to use EventInjector to inject ESC

Hi,

 

 EventInjector.invokeEvent( new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_DOWN,Characters.ESCAPE, 0));

 

if this code is specifically for 4.5, how can we achieve the same thing in 4.3.

 

I want the same effect - Invoke the camera and wait till the picture is taken and then exit from the camera app automatically and return to my app screen where I was before.

 

I have seen this in facebook., our client is too asking for the same effect.

 

Our app is on device os 4.3 onwards, kindly help me on this.

 

Thanks and Rgds.