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
New Developer
Posts: 160
Registered: ‎03-02-2011
My Device: Not Specified

FileSystemJournalListener and Camera Invoke. URGENT

Hello,

 

I am making an application that accesses to the native camera application and takes a picture from it. When the picture is saved, i want the cam application to be closed and return the result to me. I managed to do this as follows:

1- Invoke the cam application

2- UiApp.getUiApplication().addFileSystemJournalListener(new FileExplorerDemoJournalListener(this)); that will add a FileSystemJournalListener to the system. 

3- In this FileSystemJournalListener, I enter the corresponding code to perform.

 

On the simulator, everything look fine. The Camera application is invoked and when a picture is taken, it will be closed and the pic will be added to the application. When I installed the application on Blackberry cellphones, I had a problem!!!

The app worked on one device out of 6!! The other devices invoke the camera, but when a picture is taken, nothing happens. Why will that work on one device and not on all devices, while all devices have the same operating system and the same camera settings??? I did a lot of researches but didn't find anything helpful.

 

Can anyone please help?

Contributor
Posts: 10
Registered: ‎02-18-2011
My Device: Not Specified

Re: FileSystemJournalListener and Camera Invoke. URGENT

[ Edited ]

I had a similar issue before.

 

It had to do with the type of event that came back in the FileSystemJournal listener. What often happens is that multiple operations are performed on the same file. So if you are only checking if the last operation was a file add. 

 

For example:

 

entry.getEvent() == FileSystemJournalEntry.FILE_ADDED

 

You may not trap the event... because there may have been a save on the file after it was added.

 

You also need to check for:

 

FileSystemJournalEntry.FILE_CHANGED

 

And this may involve a further bit of funky code where you need to go back in the history of file journal events to match up file identifiers.

New Developer
Posts: 160
Registered: ‎03-02-2011
My Device: Not Specified

Re: FileSystemJournalListener and Camera Invoke. URGENT

My code is the following:

 

 

            for (long lookUSN = nextUSN - 1; lookUSN >= _lastUSN; lookUSN -- ) { //  && msg == null; 
                FileSystemJournalEntry entry = FileSystemJournal.getEntry(lookUSN);
                
                if (entry == null) {
                    break; 
                }
                
                if (entry.getEvent() == FileSystemJournalEntry.FILE_ADDED) {
                    String path = entry.getPath();
                    if (path != null) {
                        if (path.endsWith("png") || path.endsWith("jpg") || path.endsWith("bmp") || path.endsWith("gif") ){
                            EventInjector.KeyEvent inject = new EventInjector.KeyEvent(EventInjector.KeyEvent.KEY_DOWN,Characters.ESCAPE, 0, 50);
                            inject.post();
                            break;
                        }
                    }
                }
            }
            _lastUSN = nextUSN;
        }

 

So i dont guess that your solution will solve the problem! cause I already used it in my code. 

 

What can the solution of this problem be?

 

Contributor
Posts: 10
Registered: ‎02-18-2011
My Device: Not Specified

Re: FileSystemJournalListener and Camera Invoke. URGENT

Do all the devices have SD cards... I have found that sometimes FileSystemJournalListener doesn't work so well when the images aren't being saved to SD.

New Developer
Posts: 160
Registered: ‎03-02-2011
My Device: Not Specified

Re: FileSystemJournalListener and Camera Invoke. URGENT

Yeah i searched about this topic too. And yes all off the devices have an SDCard. The confusing is that all the devices are the same!! So why it is working only on one device!! I checked too the location where the images are saved and it is the same location

Contributor
Posts: 10
Registered: ‎02-18-2011
My Device: Not Specified

Re: FileSystemJournalListener and Camera Invoke. URGENT

If you are able to debug, check if it's actually getting to that for loop where you go back in history... (otherwise write out some log files to see if it gets there).. At least then you might start getting idea on where it is failing. You can try instead of exiting on null, executing the code after only if the entry != null .... who knows maybe there are null entries that pop up for some bizarre reason, and that stops the whole loop.

 

I remember that i didn't store the the last journal number that I read... but instead would only look back 10 entries in the journal entries to try and find one where a file was added.

Contributor
Posts: 10
Registered: ‎02-18-2011
My Device: Not Specified

Re: FileSystemJournalListener and Camera Invoke. URGENT

The other thing you can also start looking into is to ensure that the listener is really present when the call to taking the picture is made... maybe for some reason something could be going wrong, causing that listener to be invalidated. A re-creation of the screen or something equally bizarre.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: FileSystemJournalListener and Camera Invoke. URGENT

Is the problem that the Listener is not invoked, or that the Listener does not close the Camera?

New Developer
Posts: 160
Registered: ‎03-02-2011
My Device: Not Specified

Re: FileSystemJournalListener and Camera Invoke. URGENT

Hey Peter, the problem is that the listener isn't invoked because there are several functions to perform before closing the camera and none of them is applied.

New Developer
Posts: 160
Registered: ‎03-02-2011
My Device: Not Specified

Re: FileSystemJournalListener and Camera Invoke. URGENT

Peter I checked the Alt + lglg on the device. I concluded that the FileSystemJournalListener is running on all devices. But the problem is that on the 6 devices, it is throwing an exception. The exception is: "

ControlledAccessException" wich means that a thread attempts to access a controlledAccess object without the appropriate permission. So please any idea how to solve this problem?