EventInjector

I'm trying this code I found here. Looked nice.

EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent)
KeyCodeEvent.KEY_DOWN, Keypad.KEY_END, KeypadListener.STATUS_NOT_FROM_KEYPAD (char));
EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent)
KeyCodeEvent.KEY_UP, Keypad.KEY_END, KeypadListener.STATUS_NOT_FROM_KEYPAD (char));
EventInjector.invokeEvent (pressEndKey);
Thread.Sleep (50);
EventInjector.invokeEvent (releaseEndKey);
Thread.Sleep (50);
EventInjector.invokeEvent (pressEndKey);
Thread.Sleep (50);
EventInjector.invokeEvent (releaseEndKey);
Thread.Sleep (50);

gives me a bunch of error messages. as:

Cannot find the symbol keyboard

Inconvertible types found on the keyboard. KEY_END

I don't know if it's just a typo error but your keyboard. KEY_END must be Keypad.KEY_END?

Tags: BlackBerry Developers

Similar Questions

  • How can I use EventInjector.TrackwheelEvent to scroll to the right and left?

    I need to simulate a right wheel and a wheel left action.

    I used to scroll up and down the following successfully:

    EventInjector.TrackwheelEvent.THUMB_ROLL_UP

    EventInjector.TrackwheelEvent.THUMB_ROLL_DOWN

    Any ideas?

    On devices on the wheel, by using Alt + scroll is used by many applications for the movement of left and right.

    If you target trackball devices, you can navigate in all directions by injecting an EventInjector.NavigationEvent event.

  • With the help of EventInjector

    I use BlackBerry 8520. I'm developing an application to implement the functionality of EventInjector. In my application I spawn a thread that is supposed to type a phone number on the home screen. As soon as I launch the application, I return to the home screen and wait for the number to type. Here is the code I use, but I'm unable to implement the features you want.

    Just to inform, I used the code on Simulator and device

    KeyPress EventInjector.KeyCodeEvent = new EventInjector.KeyCodeEvent (EventInjector.KeyCodeEvent.KEY_DOWN, Characters.DIGIT_NINE, KeypadListener.STATUS_ALT, 3000);

    EventInjector.KeyCodeEvent keyRelease = new EventInjector.KeyCodeEvent (EventInjector.KeyCodeEvent.KEY_UP, Characters.DIGIT_NINE, KeypadListener.STATUS_ALT, 3000);

    keyPress.post ();

    keyRelease.post ();

    Sleep(); sleep for 5 seconds

    keyPress = new EventInjector.KeyCodeEvent (EventInjector.KeyCodeEvent.KEY_DOWN, Characters.DIGIT_EIGHT, KeypadListener.STATUS_ALT, 3000);

    keyRelease = new EventInjector.KeyCodeEvent (EventInjector.KeyCodeEvent.KEY_UP, Characters.DIGIT_EIGHT, KeypadListener.STATUS_ALT, 3000);

    keyPress.post ();

    keyRelease.post ();

    Sleep(); sleep for 5 seconds

    keyPress = new EventInjector.KeyCodeEvent (EventInjector.KeyCodeEvent.KEY_DOWN, Characters.DIGIT_SEVEN, KeypadListener.STATUS_ALT, 3000);

    keyRelease = new EventInjector.KeyCodeEvent (EventInjector.KeyCodeEvent.KEY_UP, Characters.DIGIT_SEVEN, KeypadListener.STATUS_ALT, 3000);

    keyPress.post ();

    keyRelease.post ();

    Sleep(); sleep for 5 seconds

    Solved...

  • EventInjector getStatus()

    Hello again

    I can't find the documentation on the values returned from getStatus(), is there someone who knows where to find that?

    Thank you.

    Support person 3: it comes to the STATUS_ * fields defined in the KeypadListener method.  It is documented in the constructors for classes of EventInjector, but not within get/setStatus.  I have this so added note to avoid any future confusion.

  • Cannot close the camera using EventInjector for touchscreen models

    Hi all

    In my application, I opened the app native camera help

    Invoke.invokeApplication (Invoke.APP_TYPE_CAMERA, new CameraArguments());

    I have a listener added to monitor changes made to the file system. As soon as a new image is taken and added to the file system, the camera is close to the EventInjector.

    I'm running it on JRE 5 and 6, and it works very well for models with no touch screen on the Simulator. However, it will not work for 9550 and 9800. On simulators, it is frozen just after the photo is taken (and probably saved). I loaded my torch, the photo is taken, then he brought me to the camera application instead to close the camera and take back me to my request.

    There should not be a problem with my code, as I moved to a programme of work. So what could be the problem?

    Same assumptions or any help would be appreciated.

    Thank you very much

    Tina

    Hey everybody,

    I solved the problem... It's because you don't have the appropriate permissions for your application to INJECT key events... Use the following code to request the appropriate permissions and you'll be on your way to the injection of events!

               ApplicationPermissionsManager permManager = ApplicationPermissionsManager.getInstance();
    
                if(permManager.getPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION ) != ApplicationPermissions.VALUE_ALLOW ||                permManager.getPermission(ApplicationPermissions.PERMISSION_IDLE_TIMER ) != ApplicationPermissions.VALUE_ALLOW  )             {             //Request our permission to inject events             ApplicationPermissions pAppPermission = new ApplicationPermissions();
    
                pAppPermission.addPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION);               pAppPermission.addPermission(ApplicationPermissions.PERMISSION_IDLE_TIMER);
    
                  if( permManager.invokePermissionsRequest(pAppPermission) == false)                {
    

    Please give Kudos if it solves your problem

  • EventInjector Keycodes

    Could someone tell what's the correct nomenclature for the following with regard to the implementation of EventInjector.KeyCodeEvent?

    SHIFT key

    Enter key

    ESC key

    Return back or remove key

    Thank you.

    If you add one of the indicators of KeypadListener, you should be able to find what you need.

    http://www.BlackBerry.com/developers/docs/5.0.0api/NET/rim/device/API/system/KeypadListener.html

    For what is enter, go back, to escape or remove:

    Characters.ENTERCharacters.BACKSPACECharacters.ESCAPECharacters.DELETE
    

    Must be injected in your keyCodeEvent as a parameter "tank".

    EventInjector.invokeEvent( new EventInjector.KeyEvent(EventInjector.KeyEvent.KEY_UP, Characters.DELETE, KeypadListener.STATUS_SHIFT) );
    

    The above should simulate a shift + delete.

  • EventInjector for NumLock does not result

    I have search high and low (I'm sure that's what everyone says) but I can't get the EventInjector to work. Here's my situation

    I have an EditField which takes input like a currency (10.00 or 12.56) field. I have a TextFilter on the ground so that the only acceptable characters are numbers and the '.' It works very well.

    Now, I am trying to affect the onFocus() NumLock field (123 in the top right corner) of the EditField. Then I thought, use the EventInjector for the KEY_ALT and the SHIFT_LEFT. Here is my code, which produces no result.

    JDE is 4.7

    running on devices that have the OS 4.6 and higher only

    public EditField amountField(String label, String value, int max, long style){
            EditField _field = new EditField(label, value, max, style){
                protected void onFocus(int direction){
                    //Dialog.alert("gained focus");
                    try {
    
                    EventInjector.KeyCodeEvent altKeyDown = new EventInjector.KeyCodeEvent(
                            EventInjector.KeyCodeEvent.KEY_DOWN,
                            ((char) Keypad.KEY_ALT),
                            0);
                    altKeyDown.post();
                    EventInjector.KeyCodeEvent shiftKeyDown = new EventInjector.KeyCodeEvent(
                            EventInjector.KeyCodeEvent.KEY_DOWN,
                            ((char) Keypad.KEY_SHIFT_LEFT),
                            KeypadListener.STATUS_ALT);
                    shiftKeyDown.post();
                    EventInjector.invokeEvent( new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_UP,
                            (char)Keypad.KEY_SHIFT_LEFT,
                            KeypadListener.STATUS_ALT));
                    EventInjector.invokeEvent( new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEvent.KEY_UP,
                    (char)Keypad.KEY_ALT, 0));
                } catch (Exception e) {
                    System.out.println("ExpenseSreen_amountField (Error) " + e.getClass() + ":  " + e.getMessage());
                }
    
                }
    
                protected void onUnfocus(){
                    Dialog.alert("lost focus");
                }
            };
        return _field;
       }
    

    Can anyone suggest what I do wrong?

    As a side note, I already have the default permissions for my application to ALLOW for EVERYTHING.

    new EditField("Amount: ", "", 10, EditField.FILTER_REAL_NUMERIC);
    

    Everything you need...

  • How to use EventInjector to inject the ESC

    Hi all.

    I'm trying to remove those (in my case) "nag" dialog boxes that appear if the appeal fails, 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();
    

    who all have two work fine on the Simulator (2.9.0.52), but in the application, I get a strange error:

    EventInjector$ KeyEvent$. Nout found

    Basicall, I just want to end on the popup screen (I guess that's a warning screen that I can't catch any other way, right?).

    Hello

    Following work 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.

  • EventInjector works in the emulator but not on the phone.

    Long time listener, first time caller...

    (1) I use the version of the plugin or Eclipse JDE (. 64)

    (2) I use the pack 4.5 component (. 16) to launch the 8330 emulator.

    (3) I have a phone of Verizon 8330 with CDMA, V4.5.077 (Platform 3.2.0.51)

    (4) I'm signing certs installed properly for RBB, RRT and CPR.

    (5) I read the examples for headphones to phone, phone call and the Injection of the event.

    (6) I tried to manually set permissions in options > advanced

    I'm trying to write an app that interrupts a call initiated by the user and redirects to another number.

    This works very well in the emulator.

    However, the following code snippet generates an error of "No sig of 0 x 33" on the 8330. This occurs even if the application is duly signed.

    EventInjector.KeyCodeEvent releaseEndKey=new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_UP,(char)Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD,100);
    
    EventInjector.invokeEvent(pressEndKey);
    

    But curiously

    System.out.println("the injector perm is " + ApplicationPermissionsManager.getInstance().getApplicationPermissions().getPermission(ApplicationPermissions.PERMISSION_EVENT_INJECTOR));
    

    indicates the value of 999 perm which apparently means it's allowed.

    So my only guess is that Verizon phones do not allow outbound calls to be interrupted by program.

    Can someone confirm or deny or otherwise tell me please what the hell I am doing wrong?

    CODE COMPLETE BELOW IN THE CASE WHERE IT IS USEFUL

    SDdemo.java

    import net.rim.blackberry.api.invoke.Invoke;
    import net.rim.blackberry.api.invoke.PhoneArguments;
    import net.rim.blackberry.api.phone.*;
    import net.rim.device.api.applicationcontrol.ApplicationPermissions;
    import net.rim.device.api.applicationcontrol.ApplicationPermissionsManager;
    import net.rim.device.api.system.EventInjector;
    import net.rim.device.api.system.KeypadListener;
    import net.rim.device.api.system.EventInjector.KeyCodeEvent;
    import net.rim.device.api.ui.Keypad;
    
    import java.util.Timer;
    import java.util.TimerTask;
    
    public final class SDdemo extends AbstractPhoneListener {
    
      private String mTarget;
      private Timer mTimer;
      private CallTask mCallTask;
    
      private static SDdemo mInstance;
    
      static public void main(String[] args)
      {
        SDdemo.registerOnStartup();
      }
    
      static private void registerOnStartup()
      {
    
        System.out.println("@@@@ phone listener start up");
        mInstance= new SDdemo();
        Phone.addPhoneListener(mInstance);
    
        requestApplicationPermissions();
    
      }
      private SDdemo(){}
    
      private void checkCall(String ehandler, int callid)
      {
        PhoneCall callInfo = Phone.getCall(callid);
    
        if ( callInfo != null ) {
          /*
           * Event Handler: ehandler
           * Telephone No.: callInfo.getDisplayPhoneNumber();
           * Elapsed Time : callInfo.getElapsedTime();
           * Call Status  : callInfo.getStatusString();
          */
    
            System.out.println("@#@#@#  the call is " + callInfo.getDisplayPhoneNumber());
            System.out.println("2@#@#@#  the status is " +  callInfo.getStatusString());
            System.out.println("3@#@#@#  the handle is " +  ehandler);
    
            mTarget = callInfo.getDisplayPhoneNumber();
    
        }
      }
    
      static private void requestApplicationPermissions() {
              //      Set permissions for the application
    
          System.out.println("@@@@@@ We are now requesting premissions");
    
          try{
              ApplicationPermissions ap1 = ApplicationPermissionsManager.getInstance().getApplicationPermissions();
    
              System.out.println("the injector perm is " + ap1.getPermission(ApplicationPermissions.PERMISSION_EVENT_INJECTOR));
    
              ApplicationPermissions ap2 = new ApplicationPermissions();
              boolean needPermission=false;
              if(ap1.getPermission(ApplicationPermissions.PERMISSION_PHONE)!=ApplicationPermissions.VALUE_ALLOW ){
                  needPermission=true;
                  ap2.addPermission(ApplicationPermissions.PERMISSION_PHONE);
              }
              if(ap1.getPermission(ApplicationPermissions.PERMISSION_EVENT_INJECTOR)!=ApplicationPermissions.VALUE_ALLOW ){
                  needPermission=true;
                  ap2.addPermission(ApplicationPermissions.PERMISSION_EVENT_INJECTOR);
                  ap2.addPermission(ApplicationPermissions.PERMISSION_IDLE_TIMER);
                  ap2.addPermission(ApplicationPermissions.PERMISSION_CHANGE_DEVICE_SETTINGS);
              }
              if(needPermission){
                 // Dialog.inform("Please save the permissions manually");
                  boolean permission=ApplicationPermissionsManager.getInstance().invokePermissionsRequest(ap2);
                //  if(!permission){
                //                                  Status.show("Application is exiting",3000);
                //      myApp.exitApplication();
                //  }
              }
            }catch(Exception e){
                  System.out.println("~~~Exception while setting permissions"+e);
            }
        }
    
      // A call has been added to a conference call
      public void callAdded(int callId)
      { checkCall("callAdded", callId); }
    
      // User answered a call
      public void callAnswered(int callId)
      { checkCall("callAnswered", callId); }
    
      // Conference call established
      public void callConferenceCallEstablished(int callId)
      { checkCall("callConferenceCallEstablished", callId); }
    
      // Network indicates a connected event
      public void callConnected(int callId)
      { checkCall("callConnected", callId); 
    
        System.out.println("Sending DTMF for " + mTarget);
    
        Phone.getActiveCall().sendDTMFTones(mTarget);
    
        System.out.println("DTMF SENT");
      }
    
      // Direct-connect call connected
      public void callDirectConnectConnected(int callId)
      { checkCall("callDirectConnectConnected", callId); }
    
      // Direct-connect call disconnected
      public void callDirectConnectDisconnected(int callId)
      { checkCall("callDirectConnectDisconnected", callId); }
    
      // Call disconnected
      public void callDisconnected(int callId)
      { checkCall("callDisconnected", callId); }
    
      // User ended call
      public void callEndedByUser(int callId)
      { checkCall("callEndedByUser", callId); }
    
      // Call has been placed on "hold"
      public void callHeld(int callId)
      { checkCall("callHeld", callId); }
    
      // New call has arrived
      public void callIncoming(int callId)
      { checkCall("callIncoming", callId); }
    
      // Outbound call initiated by the handheld
      public void callInitiated(int callid)
      { 
    
          System.out.println("@@@@ Call init");
          System.out.println("the injector perm is " + ApplicationPermissionsManager.getInstance().getApplicationPermissions().getPermission(ApplicationPermissions.PERMISSION_EVENT_INJECTOR));
    
          System.out.println(mTarget.length() + " len PBX" + mPBXcall);
    
          if (mTarget.length()==4)
          {
    
              EventInjector.KeyCodeEvent pressEndKey=new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_DOWN,( char)Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD,100);
              EventInjector.KeyCodeEvent releaseEndKey=new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_UP,(char)Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD,100);
    
              System.out.println("###@@  calling inject 1");
    
             EventInjector.invokeEvent(pressEndKey);
              System.out.println(" ###@@ calling inject 2");
    
             EventInjector.invokeEvent(releaseEndKey);
              System.out.println("###@@ calling inject 3");
    
             EventInjector.invokeEvent(pressEndKey);
              System.out.println("###@@ calling inject 4");
    
             EventInjector.invokeEvent(releaseEndKey);
              System.out.println("###@@ calling inject DONE");
    
              mTimer = new Timer();
              mCallTask = new CallTask(mTarget);
              mTimer.schedule(mCallTask, 2000);
    
          }       
    
      }
    
      // Call removed from a conference call
      public void callRemoved(int callId)
      { checkCall("callRemoved", callId); }
    
      // Call taken off of "hold"
      public void callResumed(int callId)
      { checkCall("callResumed", callId); }
    
      // Call is waiting
      public void callWaiting(int callid)
      { checkCall("callWaiting", callid); }
    
      // Conference call has been terminated
      // (all members disconnected)
      public void conferenceCallDisconnected(int callId)
      { checkCall("conferenceCallDisconnected", callId); }
    
      // Call failed
      public void callFailed(int callId, int reason)
      {
        checkCall("callFailed", callId);
    
        // determine reason
        switch( reason ) {
          case PhoneListener.CALL_ERROR_AUTHORIZATION_FAILURE: break;
          case PhoneListener.CALL_ERROR_CALL_REPLACED_BY_STK: break;
          case PhoneListener.CALL_ERROR_CONGESTION: break;
          case PhoneListener.CALL_ERROR_CONNECTION_DENIED_BY_NETWORK: break;
          case PhoneListener.CALL_ERROR_DUE_TO_FADING: break;
          case PhoneListener.CALL_ERROR_EMERGENCY_CALLS_ONLY: break;
          case PhoneListener.CALL_ERROR_FDN_MISMATCH: break;
          case PhoneListener.CALL_ERROR_GENERAL: break;
          case PhoneListener.CALL_ERROR_HOLD_ERROR: break;
          case PhoneListener.CALL_ERROR_INCOMING_CALL_BARRED: break;
          case PhoneListener.CALL_ERROR_LOST_DUE_TO_FADING: break;
          case PhoneListener.CALL_ERROR_MAINTENANCE_REQUIRED: break;
          case PhoneListener.CALL_ERROR_NUMBER_NOT_IN_SERVICE: break;
          case PhoneListener.CALL_ERROR_NUMBER_UNOBTAINABLE: break;
          case PhoneListener.CALL_ERROR_OUTGOING_CALLS_BARRED: break;
          case PhoneListener.CALL_ERROR_PLEASE_TRY_LATER: break;
          case PhoneListener.CALL_ERROR_RADIO_PATH_UNAVAILABLE: break;
          case PhoneListener.CALL_ERROR_SERVICE_CONFLICT: break;
          case PhoneListener.CALL_ERROR_SERVICE_NOT_AVAILABLE: break;
          case PhoneListener.CALL_ERROR_SUBSCRIBER_BUSY: break;
          case PhoneListener.CALL_ERROR_SYSTEM_BUSY_TRY_LATER: break;
          case PhoneListener.CALL_ERROR_TRY_AGAIN: break;
          case PhoneListener.CALL_ERROR_USER_BUSY_IN_DATA: break;
          case PhoneListener.CALL_ERROR_USER_BUSY_IN_PRIVATE: break;
          case PhoneListener.CALL_ERROR_USER_NOT_AUTHORIZED: break;
          case PhoneListener.CALL_ERROR_USER_NOT_AVAILABLE: break;
          case PhoneListener.CALL_ERROR_USER_NOT_REACHABLE: break;
        }
      }
    }
    

    CallTask.java

    import java.util.TimerTask;
    
    import net.rim.blackberry.api.invoke.Invoke;
    import net.rim.blackberry.api.invoke.PhoneArguments;
    
    public class CallTask extends TimerTask {
    
        public String mCallTarget;
    
        public CallTask(String _target)
        {
            mCallTarget = _target;
        }
    
        public void run() {
    
            System.out.println("calling task dial");
    
            PhoneArguments call = new PhoneArguments(PhoneArguments.ARG_CALL,"555-867-5309");
            Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, call);
    
        }
    
    }
    

    Thank you for pointing me in the right direction almeida.

    In case this help someone else:

    (1) looking at conducting thread me section of the knowledge base on problems with "52525400 = RIM Runtime API" line missing in the CSL file when using JDE.

    (2) I use Eclipse JDE plugin. When I looked in the file AREA, this tag was present.

    (3) poking around a little more, I noticed this tag was missing from the CSO file. So I added, why not?

    (4) things like magically started working. I go out, it stops working again.

    For Eclipse IDE using JDE plugin, I'm so going on a branch and saying: you must add '52525400 = RIM Runtime API' to your CSO file.

  • Accelerometer and EventInjector

    It is possible to simulate the events of the accelerometer on a device using EventInjector or some other API?  For example, an application can simulate an event ORIENTATION_TOP_UP?  Or, is it possible to simulate specific values of G-force per axis?

    No, this is not supported.

  • Remote display

    I'm developing an application (shutoff) to control the device on the web page. I can't able to take screenshots of the device and send to the web page and same can be shown.

    Now how to raise the event on the device as TrackBallevent or button click event to open applications on the device by jusy giving x, y positions.
    developing a (shutoff) application to control the device on the web page. I can't able to take screenshots of the device and send to the web page and same can be shown. Now how to raise the event on the device as TrackBallevent or button click event to open applications on the device by jusy giving x, y positions.

    EventInjector.NavigationEvent is used to inject a trackball clicks and movement.  You can specify the movement using the setAmount (int dx, int dy) method.

  • Permissions of the application (injection hits)

    I'm developing a phone dialer application using firmware 4.5 on a BB curve. However the EventInjector fails with an exception of nowhere. I have read that I need to goto Options-> Advanced-> applications, find my app and expand "Interactions" - injection type change "'' to 'Allow'."

    However my request does not appear in the list of applications! So, how can I activate this permission?

    Also is it possible to programmatically activate this? I don't want our customers to have to get dirty with the permissions of the application manually so that it can work.

    Thanks in advance.

    Look at this package:

    'net.rim.device.api.applicationcontrol '.

  • Configure net_rim_bb_clock programaticly

    Hello! I want to configure net_rim_bb_clock programaticly and I used this code:

    Huntington int = CodeModuleManager.getModuleHandle ("k net_rim_bb_cloc");
    If (mh! = 0) {}
    ApplicationDescriptor ad = CodeModuleManager.getApplicationDescriptors (mh) [0];
    ApplicationManager.getApplicationManager (.runAppl ication (ad, true));
    }

    In addition, I used EventInjector to indicate the alarm time.

    In the Simulator, it works perfectly, but inside, I have an exception:

    net.rim.device.api.system.ApplicationManagerExcept ion: error at startup null: null

    How could I solve this problem?

    I try to do with the code:

    Huntington int = CodeModuleManager.getModuleHandle ("k net_rim_bb_cloc");
    If (mh! = 0) {}
    ApplicationDescriptor template = CodeModuleManager.getApplicationDescripto rs (mh) [0];

    String [] args = {"75600000","on"};    Net_rim_bb_clock settings
    ApplicationDescriptor ad = new ApplicationDescriptor (template, args);

    ApplicationManager.getApplicationManager (.runAppl ication (ad, true));
    }

    But I have the same problem, where is my mistake?

    Thank you!

    Thank you, Jerome!

    Finally I found the solution, I post the code below:

    Huntington int = CodeModuleManager.getModuleHandle ("net_rim_bb_clock");
    If (mh! = 0) {}
    Model ApplicationDescriptor = CodeModuleManager.getApplicationDescriptors (mh) [0];
    ApplicationDescriptor descriptor = new ApplicationDescriptor (template, new String [] {});
    ApplicationManager.getApplicationManager () .runApplication (descriptor);
    }

  • Picture taken with the camera...

    Hi all

    I am currently facing a lot of problems to use the camera. After days and days of trying to change/adapt my code, you are my last hope...

    What I want to do is:

    1. Departure from camera
    2. The take a snapshot
    3. Resizing in my application
    4. Store in the FET (don't cause me problems)

    Here is part of my code:

    1. Beginning camera & look the file system
        public CameraBlackBerry() {
    //            invoking camera
            UiApplication.getApplication().addFileSystemJournalListener(this);
            Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA, new CameraArguments());
        }
    

    2 get path to the new image and transfer to another class

        public void fileJournalChanged() {
            AIDOO.debug(">>>>>>>> FS MODIFIED !!!");
            Application app = UiApplication.getApplication();
            app.removeFileSystemJournalListener(this);
            long USN = FileSystemJournal.getNextUSN();
            for (long i = USN - 1; i >= 0; i--) {
                System.out.println(">>>>>>>> FS MODIFIED !!! : " + i);
                FileSystemJournalEntry entry = FileSystemJournal.getEntry(i);
                if (entry.getEvent() == FileSystemJournalEntry.FILE_ADDED) {
                    path = entry.getPath();
                    if (path.endsWith(".jpg")) {// Try to kill camera app here by injecting esc. HAD to remove condition '&& path.indexOf("IMG") >= 0' because changed in OS6
                        //#ifdef DebugMode
                        AIDOO.debug(">>>>>>>> Found a file added ending with jpg @  :" + path);
                        //#endif
                        // Get out of camera app
                        EventInjector.KeyEvent inject = new EventInjector.KeyEvent(EventInjector.KeyEvent.KEY_DOWN, Characters.ESCAPE, 0);
                        inject.post();
                        inject.post();
                        app.requestForeground();
                        AIDOO.currentCameraBlackBerry = null;
                        new CameraBlackBerryFileHandler(path);
                        break;
                    }
                }
                if (entry == null) {
                    // we didn't find an entry.
                    break;
                }
            }
        }
    

    3. how to get a FileConnection

        private FileConnection openFile() {
            try {
                FileConnection file = (FileConnection) Connector.open("file://" + path);
                if (file != null) {
                    boolean fileExists = file.exists();
                    int existCount = 0;
                    while (!fileExists && existCount < 50) {
                        AIDOO.debug("fileExists sleeping for 100 msecond");
                        Thread.sleep(100);
                        fileExists = file.exists();
                        existCount++;
                    }
                    if (existCount < 50 && fileExists) {
                        return file;
                    } else {
                        return null;
                    }
                } else {
                    return null;
                }
            } catch (InterruptedException ex) {
                alerta = new Alert(Lng.getString(Lng.a_alert), "InterruptedException while opening picture connection : " + ex.getMessage() + "  " + ex.getClass() + " path :" + path, null, null);
                AIDOO.handleError("Exception while opening picture connection", ex);
                return null;
            } catch (IllegalArgumentException ex) {
                alerta = new Alert(Lng.getString(Lng.a_alert), "IllegalArgumentException while opening picture connection : " + ex.getMessage() + "  " + ex.getClass() + " path :" + path, null, null);
                AIDOO.handleError("Exception while opening picture connection", ex);
                return null;
            } catch (ConnectionNotFoundException ex) {
                alerta = new Alert(Lng.getString(Lng.a_alert), "ConnectionNotFoundException while opening picture connection : " + ex.getMessage() + "  " + ex.getClass() + " path :" + path, null, null);
                AIDOO.handleError("Exception while opening picture connection", ex);
                return null;
            } catch (IOException ex) {
                alerta = new Alert(Lng.getString(Lng.a_alert), "IOException while opening picture connection : " + ex.getMessage() + "  " + ex.getClass() + " path :" + path, null, null);
                AIDOO.handleError("Exception while opening picture connection", ex);
                return null;
            }
        }
    

    4 getting the stream

        private DataInputStream tryAccessingImage(FileConnection file) {
            DataInputStream is = null;
            nbBytes = 0;
            try {
                is = file.openDataInputStream();
            } catch (IOException ex) {
                return null;
            }
            if (is != null && file.canRead()) {
                try {
                    nbBytes = file.fileSize();
                    isAvailNbBytes = is.available();
                    int unreadableCount = 0;
                    while (nbBytes <= 0 && unreadableCount < 50) {
                        AIDOO.debug("fileSize problem, sleeping for 100 msecond");
                        Thread.sleep(100);
                        nbBytes = file.fileSize();
                        unreadableCount++;
                    }
                    if (unreadableCount < 50) {
                        return is;
                    } else {
                        return null;
                    }
                } catch (InterruptedException ex) {
                    String problem = Lng.getString(Lng.pic_couldnt_be_stored) + "(2) " + ex.getMessage() + "/ InterruptedException can read file : " + file.canRead() + " " + nbBytes + "bytes / " + path;
                    append(problem, imageProblem);
                    alerta = new Alert(Lng.getString(Lng.a_alert), problem, null, null);
                    return null;
                } catch (IOException ex) {
                    String problem = Lng.getString(Lng.pic_couldnt_be_stored) + "(2) " + ex.getMessage() + "/ IOException2 can read file : " + file.canRead() + " " + nbBytes + "bytes / " + path;
                    append(problem, imageProblem);
                    alerta = new Alert(Lng.getString(Lng.a_alert), problem, null, null);
                    return null;
                }
            } else {
                alerta = new Alert(Lng.getString(Lng.a_alert), Lng.getString(Lng.pic_couldnt_be_stored) + "(2) / InterruptedException can read file : " + file.canRead() + " " + nbBytes + "bytes / " + path, null, null);
                return null;
            }
        }
    

    5 reading the stream

        private byte[] readingImage(DataInputStream is) {
            byte[] raw = new byte[(int) nbBytes];
            isReadBytes = -2; // -2 to differ from eventual -1, 0 or n (positive) returned by read()
            try {
                isReadBytes = is.read(raw);
                return raw;
            } catch (IOException ex) {
                String problem = Lng.getString(Lng.pic_couldnt_be_stored) + "readingImage " + ex.getMessage() + "/ IOException1 can read file : " + nbBytes + "bytes / " + path;
                append(problem, imageProblem);
                alerta = new Alert(Lng.getString(Lng.a_alert), problem, null, null);
                return null;
            }
        }
    

    6 then I do the following

    try {
                            is.close();
                            screenWidth /= 4;
                            screenWidth *= 3;
                            screenHeight /= 4;
                            screenHeight *= 3;
                            append("resizing image", imageBlank16);
                            raw = resizeImage(raw, 640, 480);
                            append("resize for preview image", imageBlank16);
                            byte rawPreview[] = resizeImage(raw, screenWidth, screenHeight);
                            AIDOO.debug("ok here");
                            append("creating preview image", imageBlank16);
                            imagePreview = Image.createImage(rawPreview, 0, rawPreview.length);
                            AIDOO.debug("ok here2");
                            String devinceInfo = DeviceInfo.getSoftwareVersion();
                            AIDOO.debug(devinceInfo);
                            AIDOO.debug("ok here3");
                            //#if !BlackBerry_OS_46 && !BlackBerry_Older_than_46
                            //raw = resizeImage(raw);
                            nbBytes = raw.length;
                            //#endif
                            if (nbBytes > CAMERA_IMAGE_MAX_SIZE) {
                                alerta = new Alert(Lng.getString(Lng.a_alert), Lng.getString(Lng.pic_size_is_too_large) + " : " + nbBytes, null, null);
                                System.out.println("error 2 after insert");
                                returnValue = false;
                            }
                        } catch (IOException ioe) {
                            alerta = new Alert(Lng.getString(Lng.a_alert), "IOException : " + ioe.getMessage() + "available Bytes : " + nbBytes, null, null);
                            AIDOO.handleError("IO problem while saving picture 0", ioe);
                            System.out.println("error 2 after insert");
                            returnValue = false;
                        }
    

    7 Behold my image resizing function

        private byte[] resizeImage(byte[] image, int width, int height) {
            AIDOO.debug("Start of image resizing");
            Bitmap bmp1 = null, bmp2 = null;
            try {
                bmp1 = Bitmap.createBitmapFromBytes(image, 0, -1, 1);
                bmp2 = new Bitmap(width, height);
            } catch (IllegalArgumentException ex) {
                throw new IllegalArgumentException("exception while createBitmapFromBytes()" + ex.getMessage() + "isAvailNbBytes = " + isAvailNbBytes + " isReadBytes = " + isReadBytes + " length = " + image.length + " nbBytes = " + nbBytes + " image = " + image);
            }
            AIDOO.debug("Scale into");
            bmp1.scaleInto(bmp2, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_TO_FIT);
            AIDOO.debug("End of Scale into");
            JPEGEncodedImage encoded = JPEGEncodedImage.encode(bmp2, 90);
            return encoded.getData();
        }
    

    My problems are:

    1. sometimes the image is cropped, this size (w/h) is OK, but for some strange reason it is not all the time. There is always a large black area at the bottom of the image. It seems that something has not been correctly readen.

    2. sometimes I had an IllegalArgumentException in createBitmapFromBytes() function.

    I read a lot of posts that talk about these problems, but I have found no solution.

    Is it so hard to take a picture of the camera and display it?

    Anyone have a good example/code example on how to handle this?

    Thank you for your support and for reading me

    (Sorry for my English )

    I suspect that these problems are caused by the fact that the earpiece of the paper you use is told on the file being written until the writing is actually completed.

    I think that Ihad this problem in an application that I wrote and to get around it, rather than process the image in the JournalListener, I actually got the JournalListener to save the file created in the method of invocation of the "onExposed" screen, I checked to see if the name of the file has been updated and if so , I would treat it then.  onExposed is not get leads until the camera application has closed at this time, according to me, that it is save saying that the file has been saved.

    I think that there are other options.  For example, you could start a thread check the size of the file and if it does not grow after a second or two, you might assume that the writing was completed.

    In all cases, this is where I would start looking for the problem.

  • While using camera in my current screen close request

    Hello

    I'm creating an application to send the form camera Images and gallary,

    (1) if I press the camera button in my application I want to capture image and show that image to the current screen.

    currenltly 2) I use below functioin to do, but the first use of the user application is invited to give permission to use the camera after that if we allow so the current screen is closed. before that it is capturing the picture.

    (3) if the use the application even after leaving the second time there is no closure of the current screen and it works fine.

    All of the suggestions. can be given permissions such as the use of the camera before even install app in android permissions.

    The function that I used is

    public void uploadPhotoFromCamera (final int flagg) {}
    final FileSystemJournalListener listener = new FileSystemJournalListener()
    {
    long lastUSN;
    long a = lastUSN;
    Public Sub fileJournalChanged()
    {
    try {}
    Thread.Sleep (50);
    } catch (InterruptedException e) {}
    Generative TODO catch block
    e.printStackTrace ();
    }
    Long USN = FileSystemJournal.getNextUSN ();
    external: for (long I = USN - 1; i > = lastUSN;--i))
    {
    Entry FileSystemJournalEntry = FileSystemJournal.getEntry (i);
    If (input! = null)
    {
    If (entry.getEvent () is FileSystemJournalEntry.FILE_ADDED)
    {
    If (entry.getPath () .indexOf (".jpg")! = - 1).
    {
    lastUSN = USN;
    photoPath = entry.getPath ();
    Try
    {
    acceptance of Boolean = false;
    APM ApplicationPermissionsManager = ApplicationPermissionsManager.getInstance ();
    Original ApplicationPermissions = apm.getApplicationPermissions ();

    ApplicationPermissions permRequest = new ApplicationPermissions();
    If (original.getPermission (ApplicationPermissions.PERMISSION_INPUT_SIMULATION)! = ApplicationPermissions.VALUE_ALLOW)
    {
    permRequest.addPermission (ApplicationPermissions.PERMISSION_INPUT_SIMULATION);
    permRequest.addPermission (ApplicationPermissions.PERMISSION_AUTHENTICATOR_API);
    permRequest.addPermission (ApplicationPermissions.PERMISSION_EVENT_INJECTOR);
    acceptance = ApplicationPermissionsManager.getInstance () .invokePermissionsRequest (permRequest);
    }
    //
    Inject the EventInjector.KeyEvent = new EventInjector.KeyEvent (EventInjector.KeyEvent.KEY_DOWN, Characters.ESCAPE, 50);
    EventInjector.invokeEvent (inject);
    EventInjector.invokeEvent (inject);
    EventInjector.invokeEvent (inject);

    If (photoPath! = null) {}
    Here I use this image from this path
    }

    } catch (Exception e) {}
    RIMLogger.getInstance("TraceCRM").error ("# error photo Capture >" + e.getMessage () +")<>
    }

    break outer;
    }
    }
    }
    }
    lastUSN = USN;
    }
    };

    UiApplication.getUiApplication () .addFileSystemJournalListener (listener);
    Invoke.invokeApplication (Invoke.APP_TYPE_CAMERA, new CameraArguments (CameraArguments.ARG_CAMERA_APP));
    }

    Thank you

    Ask permission before you make in this--see

    ApplicationPermissionsDemo

Maybe you are looking for