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
Posts: 231
Registered: ‎07-09-2009
My Device: Not Specified

Close Camera

Hi to all,

                I'm developing an application which have an option to take picture from my application.i have succesfully take the picture after that i want to close the camera..

 

              Can any one know how to close camera....I need to close the camera after taking picture... For this using below but it close whole application...

 

EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEv

ent.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);
Can any one pls help me....
Thanks,
Packiaraj M
Developer
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: Close Camera

Just a tip: The end key (under normal circumstances) does not close a BlackBerry application.

 

How are you opening the camera in your code?

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Highlighted
New Contributor
Posts: 3
Registered: ‎03-01-2010
My Device: Storm
My Carrier: Airtel

Re: Close Camera

Hey Packiaraj,

 

Please try this code. It may helpful for you Smiley Wink...

 

public void fileJournalChanged() 
    {
        long nextUSN = FileSystemJournal.getNextUSN();
        String msg = null;
        String newFilePath = "";
        
        for (long lookUSN = nextUSN - 1; lookUSN >= _lastUSN && msg == null; --lookUSN) 
        {
            FileSystemJournalEntry entry = FileSystemJournal.getEntry(lookUSN);
            
            // We didn't find an entry.
            if (entry == null) 
            { 
                break;
            }

            // Check if this entry was added or deleted.
            String path = entry.getPath();
            
            if (path != null) 
            {
                switch (entry.getEvent()) 
                {
                    case FileSystemJournalEntry.FILE_ADDED:
                        msg = "File was added.";           
                        newFilePath = path;             
                        EventInjector.NavigationEvent inject = new EventInjector.NavigationEvent(EventInjector.KeyEvent.KEY_DOWN, Characters.ESCAPE, 0, 50);
                        inject.post();
                        inject.post();
                        synchronized (UiApplication.getApplication().getAppEventLock()) 
                        {
                            UiApplication.getUiApplication().requestForeground();
                        }
                        //UiApplication.getUiApplication().pushModalScreen(new ImagePreview(path));
                        break;
                        
                    case FileSystemJournalEntry.FILE_DELETED:
                        msg = "File was deleted.";
                        break;
                }
            }
        }
        
        // _lastUSN must be updated before calling showMessage() because that method
        // pushes a modal screen onto the display stack, which blocks this thread.
        // If the modal screen's thread then processes a file journal event on this
        // application's behalf, the for loop above can end up processing the same
        // event that we are blocking on.  Updating _lastUSN before blocking prevents
        // the same file journal event from being processed twice, and thus prevents
        // the same dialog from being displayed twice.
        _lastUSN = nextUSN;
        
        if ( msg != null ) 
        {
            showMessage(msg);
            if(newFilePath.indexOf("jpg")>0){
                Dialog.alert(newFilePath);
                synchronized (UiApplication.getApplication().getAppEventLock()) 
                {
                    UiApplication.getUiApplication().pushModalScreen(new ImagePreview(newFilePath));
                }
            }
            else
                _screen.updateList();
        }
    }

 

Developer
Posts: 231
Registered: ‎07-09-2009
My Device: Not Specified

Re: Close Camera

Hi Carty,

               I'm using below code to open camera.. I need to close the camera after taking the picture just like facebook application Got it?

 

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

 

Thanks,

Packiaraj M

Developer
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: Close Camera

Using the above code should solve your problem.

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Developer
Posts: 231
Registered: ‎07-09-2009
My Device: Not Specified

Re: Close Camera

I have tried that but the camera not closed its running background.. i need to close the camera immediately..

 

Any idea?

Super Contributor
Posts: 273
Registered: ‎11-23-2010
My Device: 9800 torch
My Carrier: Software Programmer

Re: Close Camera