Android java zxing二维码阅读器不可在片段中自定义
我想在片段中使用二维码阅读器。当我给管理员打电话时。inititateScan()是定制的,即将发布,但不会给出响应。否则当我打电话给监管者时。forSupportFragment(Fragment2.this)。initiateScan()reader即将到来,但没有我的自定义设置和横向模式
intentIntegrator.setPrompt("Scan a qr code");
intentIntegrator.setCameraId(0); // Use a specific camera of the device
intentIntegrator.setOrientationLocked(true);
intentIntegrator.setBeepEnabled(true);
intentIntegrator.setCaptureActivity(Capture.class);
当我使用第二个选项时,这个定制并不是为reader设置的。我能做什么?我在stackoverflow中搜索主题,但我的问题没有解决
在清单xml中:
<activity
安卓:name=".Capture"
安卓:screenOrientation="fullSensor"
安卓:stateNotNeeded="true"
安卓:theme="@style/zxing_CaptureTheme"
安卓:windowSoftInputMode="stateAlwaysHidden" />
片段:
public void scanCode() {
IntentIntegrator intentIntegrator = new IntentIntegrator(getActivity());
intentIntegrator.setDesiredBarcodeFormats(IntentIntegrator.ALL_CODE_TYPES);
intentIntegrator.setPrompt("Scan a qr code");
intentIntegrator.setCameraId(0); // Use a specific camera of the device
intentIntegrator.setOrientationLocked(true);
intentIntegrator.setBeepEnabled(true);
intentIntegrator.setCaptureActivity(Capture.class);
// intentIntegrator.initiateScan();
IntentIntegrator.forSupportFragment(Fragment2.this).initiateScan();
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
IntentResult intentResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (intentResult != null) {
if (intentResult.getContents() != null) {
if (intentResult.getContents().contains(":")) {
showAlert("Connection String Found", intentResult.getContents());
profileAddressText.setText(intentResult.getContents().split(":")[0]);
} else {
showAlert("Connection String Error", "connection string not acceptible");
}
} else {
showAlert("Not found", "please fill all fields");
}
}
}
共 (0) 个答案