I want to create Custom View in Android for ZXing Scanner where the camera is in portrait mode, custom camera view dimension. I have a header and footer via fragment in the same view but I cannot make ZXing in Custom Layout. I did made it in full screen.
Sorry but I might be needing a bit of spoon feeding.
compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
compile 'com.google.zxing:core:3.2.0'
Above Library I used but It makes it full Screen using below Code:
Scan Activity:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import prizeops.com.merchant.service.CallActivityService;
import prizeops.com.merchant.service.HelperUtil;
import prizeops.com.merchant.service.PrizeService;
public class ScanActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
IntentIntegrator integrator = new IntentIntegrator(this);
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
integrator.setPrompt("Scan QRCode");
integrator.setCameraId(0);
integrator.setOrientationLocked(true);
integrator.setBeepEnabled(true);
integrator.setCaptureActivity(CaptureCodePortraitActivity.class);
integrator.initiateScan();
}
@Override
protected void onActivityResult(int req, int res, Intent intent) {
IntentResult intentResult = IntentIntegrator.parseActivityResult(req, res, intent);
if(intentResult != null){
if(intentResult.getContents()==null){
HelperUtil.makeToast(this, "Scanning been Cancelled.");
CallActivityService.gotoHomeActivity(this);
}
else
PrizeService.verifyPromoCode(this,intentResult.getContents(),false);
}
else {
super.onActivityResult(req, res, intent);
}
}
}
CaptureCodePortraitActivity:
import com.journeyapps.barcodescanner.CaptureActivity;
public final class CaptureCodePortraitActivity extends CaptureActivity {}
I saw few Github Posts but I couldn't understand how to customize that such as:
https://github.com/journeyapps/zxing-android-embedded
but no help
For opening camera in portrait mode,in the manifest add the CaptureActivity as:
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="portrait"
tools:replace="screenOrientation" />
this will replace the screen orientation=landscape which is used as default in Zxing library.