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);
}
});
}
}
添加回答
舉報