我希望我的用户使用内置相机拍摄照片作为附件。
有没有办法在按下按钮时调用相机并保存生成的照片?
另一种选择是使用 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