0
我試圖掃描QR碼並將掃描結果的值傳遞給另一個活動。我在SparseArray中得到結果並提取最新的掃描值。我無法檢索我的第二個活動中的任何字符串。任何人都可以打電話給我,如果SparseArray中的結果是字符串格式?如果沒有,我如何在字符串格式的第二個活動中接收這些值?將SparseArray的結果傳遞給另一個活動
我的MainActivity
@Override
public void receiveDetections(Detector.Detections<Barcode> detections) {
final SparseArray<Barcode> barcodes = detections.getDetectedItems();
if (barcodes.size() != 0) {
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
intent.putExtra("barcode",barcodes.valueAt(0));
startActivity(intent);
finish();
}
}
我接收活動
Intent intent = getIntent();
String barcode = intent.getStringExtra("barcode");