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

Posts: 17
Registered: ‎04-09-2012
My Device: BB9900
My Carrier: 02

Properly listening to filejournal to select image file path



I am struggling to find a way to return image file path. I have been reading Peter's replies on some posts about putting the application in the background and activating it when it finds an image. Here's the code I am using. Can anyone give me any tips or hints as to what I'm doing wrong or how to get the image path, properly.


public void fileJournalChanged() {
		// TODO Auto-generated method stub
		long nextUSN = FileSystemJournal.getNextUSN();
		String msg = null;
		 for (long lookUSN = nextUSN - 1; lookUSN >= _lastUSN && msg == null; --lookUSN) 
	            FileSystemJournalEntry entry = FileSystemJournal.getEntry(lookUSN);
	            // We didn't find an entry
	            if (entry == null) 

	            // Check if this entry was added or deleted
	            String path = entry.getPath();
	            if (path.endsWith("png") || path.endsWith("jpg") || path.endsWith("bmp") || path.endsWith("gif") ){
	                switch (entry.getEvent()) 
	                    case FileSystemJournalEntry.FILE_ADDED:
	                        msg = "File was added.";
	                    case FileSystemJournalEntry.FILE_DELETED:
	                        msg = "File was deleted.";

		 if(msg != null){


_fileListener = new FileExplorerJournalListener(this);        
        try {
			// Create an invocation instance with the specified URL
			// where the file type is one of the media types supported
			// by the media player.
			Invocation invocation = new Invocation(null, null,
					false, ContentHandler.ACTION_OPEN);
			invocation.setArgs(new String[] { BlackBerryContentHandler.MEDIA_ARGUMENT_VIEW_PICTURES });

			// Get the Registry object using the class name of the
			// application
			Registry _registry = Registry.getRegistry(Application.getApplication().getClass().getName());

			// Invoke the content handler.
		} catch (IOException e) {
			System.out.println("Camera exception: " + e.getMessage());


BlackBerry Development Advisor
Posts: 15,857
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Properly listening to filejournal to select image file path

Can you elaborate on the issue you are seeing?  The problem you are having isn't that clear.  Is the problem getting the actual path or with your background application alert the froreground app?  Are you receiving any error or exception?  


This example may help you with your application design...


Allow a background listener to detect and update a GUI application

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.