import net.rim.blackberry.api.invoke.CameraArguments;\r
import net.rim.blackberry.api.invoke.Invoke;\r
import net.rim.device.api.system.Characters;\r
+import net.rim.device.api.system.EventInjector;\r
import net.rim.device.api.ui.UiApplication;\r
import net.rim.device.api.ui.component.Dialog;\r
import net.rim.device.api.ui.component.LabelField;\r
private final ImageCapturedJournalListener captureListener;\r
\r
ZXingMainScreen() {\r
- setTitle("Barcode Reader");\r
- add(new LabelField("ZXing"));\r
+ setTitle("ZXing Barcode Reader");\r
+ add(new LabelField("UNDER CONSTRUCTION"));\r
+ add(new LabelField("1. Press 'Enter' at right to launch the Camera application"));\r
+ add(new LabelField("2. Configure Camera to capture 640x480 image"));\r
+ add(new LabelField("3. Take a picture of a barcode"));\r
+ add(new LabelField("4. If not returned to this application to see result, close Camera application"));\r
app = (ZXingUIApp) UiApplication.getUiApplication();\r
captureListener = new ImageCapturedJournalListener(this);\r
app.addFileSystemJournalListener(captureListener);\r
\r
void handleFile(String path) {\r
if (path.endsWith(".jpg") && path.indexOf("IMG") >= 0) {\r
+ // Get out of camera app\r
+ EventInjector.invokeEvent(new EventInjector.KeyEvent(EventInjector.KeyEvent.KEY_DOWN, Characters.ESCAPE, 0, 1));\r
+ EventInjector.invokeEvent(new EventInjector.KeyEvent(EventInjector.KeyEvent.KEY_UP, Characters.ESCAPE, 0, 1));\r
+ // Try to come to foreground for good measure\r
app.requestForeground();\r
try {\r
FileConnection file = null;\r
if (is != null) {\r
try {\r
is.close();\r
- } catch (IOException ioe ) {\r
+ } catch (IOException ioe) {\r
// continue\r
}\r
}\r
if (file != null) {\r
try {\r
file.close();\r
- } catch (IOException ioe ) {\r
+ } catch (IOException ioe) {\r
// continue\r
}\r
}\r
MonochromeBitmapSource source = new LCDUIImageMonochromeBitmapSource(capturedImage);\r
Reader reader = new MultiFormatReader();\r
Result result = reader.decode(source);\r
+ // If decode was successful...\r
try {\r
file.delete();\r
} catch (IOException ioe) {\r