zxing not working

91 views
Skip to first unread message

xavier flamant

unread,
Jul 3, 2016, 6:37:42 AM7/3/16
to zxing
Hello, I am trying to use zxing framework to scan qr barcode.Here is my code

public void scanbarcode(View v) {
Log.i(APP_TAG, "Scan!");
Intent scanIntent = new Intent("com.google.zxing.client.android.SCAN");
PackageManager packageManager = this.getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(scanIntent, 0);
if(activities.size() > 0){
Log.i(APP_TAG, "StartActivity Scan!");
this.startActivityForResult(scanIntent, BARCODE_SCANNED);
}

}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
ImageView imageView = (ImageView)this.findViewById(R.id.showphoto);
Log.i(APP_TAG, "MainActivity1.onActivityResult(): debut !");
Log.i(APP_TAG, "requestCode="+requestCode);
Log.i(APP_TAG, "resultCode="+resultCode);

if (requestCode == BARCODE_SCANNED) {
Log.i(APP_TAG, "On recupere un code barre");
String code = data.getStringExtra("SCAN_RESULT");
Log.i(APP_TAG, "-> "+code);
this.tv = (TextView) this.findViewById(R.id.barCodeResult);
this.tv.setText(code);
}
}

But it doesn't work; normally it should take a photo on the camera of the bar code ? I am right ? Furthermore My method onActivityResult seems not to be called : I have no log

Here is the log :
07-03 12:27:34.153 11275-11275/com.example.admin.projetcnam W/ViewRootImpl: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=465.41382, y[0]=541.23047, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=62469868, downTime=60062012, deviceId=0, source=0x1002 }
07-03 12:27:34.153 11275-11275/com.example.admin.projetcnam W/ViewRootImpl: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=465.41382, y[0]=541.23047, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=62469868, downTime=60062012, deviceId=0, source=0x1002 }
07-03 12:27:34.153 11275-11275/com.example.admin.projetcnam W/ViewRootImpl: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=465.41382, y[0]=541.23047, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=62469868, downTime=60062012, deviceId=0, source=0x1002 }
07-03 12:27:34.153 11275-11275/com.example.admin.projetcnam W/ViewRootImpl: Cancelling event due to no window focus: MotionEvent { action=ACTION_CANCEL, actionButton=0, id[0]=0, x[0]=465.41382, y[0]=541.23047, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=62469868, downTime=60062012, deviceId=0, source=0x1002 }
07-03 12:27:34.315 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: Scan!
07-03 12:27:34.318 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: StartActivity Scan!
07-03 12:27:34.363 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: MainActivity1.onPause(): beginning !
07-03 12:27:34.363 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: MainActivity1.onPause(): end !
07-03 12:27:34.425 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: MainActivity1.onCreate(): beginning !
07-03 12:27:34.462 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: MainActivity1.onCreate(): premier démarrage ca passe!
07-03 12:27:34.471 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: MainActivity1.onCreate(): end !
07-03 12:27:34.472 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: MainActivity1.onStart(): beginning !
07-03 12:27:34.472 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: MainActivity1.onStart(): end !
07-03 12:27:34.472 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: MainActivity1.onResume(): beginning !
07-03 12:27:34.472 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: MainActivity1.onResume(): end !
07-03 12:27:34.670 11275-11332/com.example.admin.projetcnam W/EGL_emulation: eglSurfaceAttrib not implemented
07-03 12:27:34.670 11275-11332/com.example.admin.projetcnam W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7f9fb74e6580, error=EGL_SUCCESS
07-03 12:27:35.047 11275-11332/com.example.admin.projetcnam E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f9fc88a43b0
07-03 12:27:35.051 11275-11332/com.example.admin.projetcnam D/OpenGLRenderer: endAllStagingAnimators on 0x7f9fb74dd800 (RippleDrawable) with handle 0x7f9fb79786e0
07-03 12:27:35.336 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: MainActivity1.onSaveInstanceState(): beginning !
07-03 12:27:35.338 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: MainActivity1.onSaveInstanceState(): end !
07-03 12:27:35.340 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: MainActivity1.onStop(): beginning !
07-03 12:27:35.340 11275-11275/com.example.admin.projetcnam I/CNAM_NFA025_TAG: MainActivity1.onStop(): end !

Andrey Nazarchuk

unread,
Jul 26, 2016, 11:27:59 PM7/26/16
to zxing
Use the example on their github page.
Reply all
Reply to author
Forward
0 new messages