I'd like my user to take a picture as an attachment by using the buil开发者_开发技巧t in camera.
Is there someway to invoke the camera on a button press and save the resulting taken picture?
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
http://docs.blackberry.com/en/developers/deliverables/17968/Take_a_picture_in_a_BB_device_app_1228201_11.jsp
精彩评论