Search code examples
androidzxinggoogle-glassgoogle-gdk

Using zxing on Google Glass


I´m trying to use the zxing on the google glass, however i´m receiving the error above.

I using the zxing 2.2 core.jar I also receive this error message on the device display "Sorry, the android camera encountered a problem. You may need to restart the device".

I´m lauching a intent on my oncreate activity

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
startActivityForResult(intent, 0);
}

Eclipse Error Message

12-16 15:29:24.578: I/PlatformSupportManager(2150): Using implementation class com.google.zxing.client.android.camera.open.GingerbreadOpenCameraInterface of interface com.google.zxing.client.android.camera.open.OpenCameraInterface for SDK 9

12-16 15:29:24.578: I/GingerbreadOpenCamera(2150): Opening camera #0

**12-16 15:29:24.585: W/CaptureActivity(2150): Unexpected error initializing camera**

12-16 15:29:24.585: W/CaptureActivity(2150): java.lang.RuntimeException: Fail to connect to camera service
12-16 15:29:24.585: W/CaptureActivity(2150):    at android.hardware.Camera.native_setup(Native Method)

12-16 15:29:24.585: W/CaptureActivity(2150):    at android.hardware.Camera.<init>(Camera.java:374)

12-16 15:29:24.585: W/CaptureActivity(2150):    at android.hardware.Camera.open(Camera.java:315)

12-16 15:29:24.585: W/CaptureActivity(2150):    at com.google.zxing.client.android.camera.open.GingerbreadOpenCameraInterface.open(GingerbreadOpenCameraInterface.java:57)

12-16 15:29:24.585: W/CaptureActivity(2150):    at com.google.zxing.client.android.camera.CameraManager.openDriver(CameraManager.java:78)

GDK Camera References (https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/media/Camera)

There is not a lot information about how use it, however there are other questions like this one

Google Glass preview image scrambled with new XE10 release

that make me think that is possible to use the zxing on glass.


Solution

  • I not including

    <uses-permission android:name="android.permission.CAMERA"/>
    

    at the top of my manifest.

    This is blocking my camera to open.

    If someone is trying to integrate zxing i suggest use this tutorial.

    http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/