<string name="menu_history">History</string>
<string name="menu_share">Share</string>
<string name="msg_about">Based on the open source ZXing Barcode Library</string>
+ <string name="msg_camera_framework_bug">Sorry, the Android camera encountered a problem. You may need to restart the device.</string>
<string name="msg_default_contents">Contents</string>
<string name="msg_default_format">Format</string>
<string name="msg_default_mms_subject">Hi</string>
private String decodeMode;
private String versionName;
private HistoryManager historyManager;
-
+
private final OnCompletionListener beepListener = new BeepListener();
private final DialogInterface.OnClickListener aboutListener =
return true;
} else if ((source == Source.NONE || source == Source.ZXING_LINK) && lastResult != null) {
resetStatusView();
- handler.sendEmptyMessage(R.id.restart_preview);
+ if (handler != null) {
+ handler.sendEmptyMessage(R.id.restart_preview);
+ }
return true;
}
} else if (keyCode == KeyEvent.KEYCODE_FOCUS || keyCode == KeyEvent.KEYCODE_CAMERA) {
CameraManager.get().openDriver(surfaceHolder);
} catch (IOException ioe) {
Log.w(TAG, ioe);
+ displayFrameworkBugMessageAndExit();
+ return;
+ } catch (RuntimeException e) {
+ // Barcode Scanner has seen crashes in the wild of this variety:
+ // java.?lang.?RuntimeException: Fail to connect to camera service
+ Log.e(TAG, e.toString());
+ displayFrameworkBugMessageAndExit();
return;
}
if (handler == null) {
}
}
+ private void displayFrameworkBugMessageAndExit() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(getString(R.string.app_name));
+ builder.setMessage(getString(R.string.msg_camera_framework_bug));
+ builder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialogInterface, int i) {
+ finish();
+ }
+ });
+ builder.show();
+ }
+
private void resetStatusView() {
resultView.setVisibility(View.GONE);
statusView.setVisibility(View.VISIBLE);