views:

62

answers:

2

I'd like my user to take a picture as an attachment by using the built in camera.

Is there someway to invoke the camera on a button press and save the resulting taken picture?

+1  A: 

The other option is to use the BlackBerry Invoke API to start the native camera application and listen for a file system event:

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

then, later:

class FileExplorerDemoJournalListener implements FileSystemJournalListener {
    public void fileJournalChanged() {
        long nextUSN = FileSystemJournal.getNextUSN();
        for (long lookUSN = nextUSN - 1; lookUSN >= _lastUSN && msg == null; --lookUSN) {
            FileSystemJournalEntry entry = FileSystemJournal.getEntry(lookUSN);
            if (entry == null) {
                break; 
            }
            String path = entry.getPath();
            if (path != null) {
                if (path.endsWith("png") || path.endsWith("jpg") || path.endsWith("bmp") || path.endsWith("gif") ){
                    switch (entry.getEvent()) {
                        case FileSystemJournalEntry.FILE_ADDED:
                            //either a picture was taken or a picture was added to the BlackBerry device 
                            break;
                        case FileSystemJournalEntry.FILE_DELETED:
                            //a picture was removed from the BlackBerry device;
                            break;
                    }
                }
            }
        }
    }
}

Finally...

Application.addFileSystemJournalListener(new FileExplorerDemoJournalListener());

This will get you most of the way there... taken from: http://docs.blackberry.com/en/developers/deliverables/11942/Detect_when_img_is_added_or_removed_file_system_740288_11.jsp

spacemanaki