zxing QRscanner 的不同结果
Different result for zxing QRscanner
我有三个不同的 EditText 和三个不同的 Qr 按钮。每个按钮 setText 到每个 EditText。谁能帮我一下。
扫一扫功能
public void scanQRCode(View view, String from) {
IntentIntegrator integrator = new IntentIntegrator(this);
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
integrator.setOrientationLocked(true);
integrator.setCameraId(0);
integrator.setBeepEnabled(false);
integrator.setBarcodeImageEnabled(false);
integrator.addExtra("from", from);
integrator.initiateScan();
}
Activity 结果
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
final IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (result != null) {
if (result.getContents() == null) {
Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
} else {
//do any.
}
} else {
// This is important, otherwise the result will not be passed to the fragment
super.onActivityResult(requestCode, resultCode, data);
}
}
我可以放一些类似 intent putextra 的东西来检查我点击了哪个按钮吗?
希望有人能帮忙。非常感谢
int clickedButton = 0;
findViewById(R.id.your_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clickedButton = 1;
}
});
findViewById(R.id.your_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clickedButton = 2;
}
});
findViewById(R.id.your_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clickedButton = 3;
}
});
在 onActivityResult 中检查 if(clickedButton == 1)
将文本设置为特定的编辑文本
我有三个不同的 EditText 和三个不同的 Qr 按钮。每个按钮 setText 到每个 EditText。谁能帮我一下。
扫一扫功能
public void scanQRCode(View view, String from) {
IntentIntegrator integrator = new IntentIntegrator(this);
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
integrator.setOrientationLocked(true);
integrator.setCameraId(0);
integrator.setBeepEnabled(false);
integrator.setBarcodeImageEnabled(false);
integrator.addExtra("from", from);
integrator.initiateScan();
}
Activity 结果
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
final IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (result != null) {
if (result.getContents() == null) {
Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show();
} else {
//do any.
}
} else {
// This is important, otherwise the result will not be passed to the fragment
super.onActivityResult(requestCode, resultCode, data);
}
}
我可以放一些类似 intent putextra 的东西来检查我点击了哪个按钮吗? 希望有人能帮忙。非常感谢
int clickedButton = 0;
findViewById(R.id.your_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clickedButton = 1;
}
});
findViewById(R.id.your_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clickedButton = 2;
}
});
findViewById(R.id.your_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clickedButton = 3;
}
});
在 onActivityResult 中检查 if(clickedButton == 1)
将文本设置为特定的编辑文本