2 回答
TA贡献1860条经验 获得超9个赞
从您的代码中,这是我的解决方案:
@Override
public void receiveDetections(Detector.Detections<Barcode> detections) {
final SparseArray<Barcode> qrCodes = detections.getDetectedItems();
if (qrCodes.size() != 0) {
textView.post(new Runnable() {
@Override
public void run() {
Vibrator vibrator = (Vibrator)getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(1000);
textView.setText(qrCodes.valueAt(0).displayValue);
sendMessage2(textView);
}
});
}
}
TA贡献1772条经验 获得超6个赞
所有代码都已经存在,只是不要拆分它:
public void receiveDetections(Detector.Detections<Barcode> detections) {
final SparseArray<Barcode> qrCodes = detections.getDetectedItems();
if(qrCodes.size()!=0)
{
Intent intent2 = new Intent(view.getContext(),QRWebActivity.class);
intent2.putExtra("EXTRA_QRMESSAGE",qrCodes.valueAt(0).displayValue);
startActivity(intent2);
textView.post(new Runnable() {
@Override
public void run() {
Vibrator vibrator = (Vibrator)getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(1000);
textView.setText(qrCodes.valueAt(0).displayValue);
}
});
}
}
添加回答
举报