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
Contributor
Posts: 31
Registered: ‎04-30-2010
My Device: Curve 8900
My Carrier: ATT

swipe in sim, but not device?

I've got a screen that shows a series of images.  I put in some code to let the user swipe to change images.  It works fine on the 9550 simulator, but nothing happens on the actual device.

 

Any ideas?

 

 

	protected boolean touchEvent(TouchEvent message){        
        boolean isConsumed = false;
        TouchGesture touchGesture = message.getGesture();           
        if (touchGesture != null){                
            if (touchGesture.getEvent() == TouchGesture.SWIPE){      
                switch(touchGesture.getSwipeDirection()){
                    case TouchGesture.SWIPE_EAST:
                		EventInjector.invokeEvent(new EventInjector.NavigationEvent(NavigationEvent.NAVIGATION_MOVEMENT, -1, 0, KeypadListener.STATUS_NOT_FROM_KEYPAD));
                    	break;

                    case TouchGesture.SWIPE_WEST:
                		EventInjector.invokeEvent(new EventInjector.NavigationEvent(NavigationEvent.NAVIGATION_MOVEMENT, 1, 0, KeypadListener.STATUS_NOT_FROM_KEYPAD));
                    	break;                            
                } 
                isConsumed = true;              
            }
        }     
        return isConsumed;       
    }

 

2791i470AD9C51C45C018

 

 

 

Contributor
Posts: 31
Registered: ‎04-30-2010
My Device: Curve 8900
My Carrier: ATT

Re: swipe in sim, but not device?

ok so I changed the permissions on device.  I changed 'simulate input' to 'enable'.  Now every time I swipe, it works but it warns the user that the app is trying to reset the security timer.  What is that all about?

Contributor
Posts: 31
Registered: ‎04-30-2010
My Device: Curve 8900
My Carrier: ATT

Re: swipe in sim, but not device?

here's what I settled on.  I run this at startup.

 

 

    private void setupPermissions()
    {
        ApplicationPermissionsManager man = ApplicationPermissionsManager.getInstance();
        int[] requiredPerms = new int[] {ApplicationPermissions.PERMISSION_CROSS_APPLICATION_COMMUNICATION, ApplicationPermissions.PERMISSION_INPUT_SIMULATION, ApplicationPermissions.PERMISSION_IDLE_TIMER, ApplicationPermissions.PERMISSION_LOCATION_DATA};
        ApplicationPermissions perms = man.getApplicationPermissions();
        
        boolean change = false;
        for(int i = 0; i < requiredPerms.length; i++)
        {
            if(perms.containsPermissionKey(requiredPerms[i]))
            {
                if(perms.getPermission(requiredPerms[i]) != ApplicationPermissions.VALUE_ALLOW)
                {
                    change = true;
                    perms.addPermission(requiredPerms[i]);
                }
            }
            else
            {
                change = true;
                perms.addPermission(requiredPerms[i]);
            }
        }
        if(change)
        {
        	Dialog.inform("This application requires elevated permissions.  When you see the 'Change Permissions' screen, please click 'Back' and then choose 'Save'.");
            man.invokePermissionsRequest(perms);
        }
    }