如何调用Blackberry相机并保存我的代码中的图片?

时间:2010-09-17 23:04:11

标签: blackberry blackberry-storm

我希望我的用户使用内置相机将照片作为附件拍摄。

是否有人在按下按钮时调用相机并保存拍摄的照片?

2 个答案:

答案 0 :(得分:2)

另一种选择是使用BlackBerry Invoke API启动本机相机应用程序并侦听文件系统事件:

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

然后,后来:

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;
                    }
                }
            }
        }
    }
}

...最后

Application.addFileSystemJournalListener(new FileExplorerDemoJournalListener());

这将让你大部分时间来自...... http://docs.blackberry.com/en/developers/deliverables/11942/Detect_when_img_is_added_or_removed_file_system_740288_11.jsp

答案 1 :(得分:1)