Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 拆分字符串时出现二维码错误_Android_Exception_Split_Qr Code - Fatal编程技术网

Android 拆分字符串时出现二维码错误

Android 拆分字符串时出现二维码错误,android,exception,split,qr-code,Android,Exception,Split,Qr Code,我使用zxing集成码扫描我的android项目中的二维码。我在字符串中得到结果,如CMD#9874563210。现在,我想拆分成两个字符串 我尝试了以下函数来拆分字符串 public void populateScanData(String scanData){ /*StringTokenizer strTkn = new StringTokenizer(scanData, "#"); ArrayList<String> arrLis = new ArrayLis

我使用zxing集成码扫描我的android项目中的二维码。我在字符串中得到结果,如CMD#9874563210。现在,我想拆分成两个字符串

我尝试了以下函数来拆分字符串

public void populateScanData(String scanData){

    /*StringTokenizer strTkn = new StringTokenizer(scanData, "#");
    ArrayList<String> arrLis = new ArrayList<String>(scanData.length());
    while(strTkn.hasMoreTokens())
        arrLis.add(strTkn.nextToken());
    String merCode = arrLis.toArray(new String[0]).toString();
    String mobileNo = arrLis.toArray(new String[1]).toString();*/

    String string = scanData;
    String[] parts = string.split("#");
    String part1 = parts[0]; // 004
    String part2 = parts[1]; // 034556

    // Set to the credit acc field
    txtCreditAcc.setText(part2);

    // Set to the redemption merchant name
    lblRedMerName.setText(part1);

}
这是我的扫描二维码

/**
 * Function to start the scan
 * @param view - The view object calling the function
 */
public void startScan(View view) {

    // Create the scanIntegrator
    IntentIntegrator scanIntegrator = new IntentIntegrator(this);

    // Start the integrator
    scanIntegrator.initiateScan();

    // Start the integrator
    AlertDialog alertDialog=scanIntegrator.initiateScan();

    if(alertDialog==null) {

        // Disable the credit account field
        txtCreditAcc.setEnabled(false);

        // disable the amount button
        txtPayAmount.setEnabled(false);

        //disable the reference button
        txtPayReference.setEnabled(false);

        //disable the debit account layout
        layDebitAccount.setEnabled(false);

    }

}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    // Store the scanning result
    IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);

    // Check if the result is null,
    if (scanningResult != null) {

        // get the scan content
        String scanContent = scanningResult.getContents();

        populateScanData(scanContent);


    } else {


        generalMethods.showToastMessage(context,"No scan data received!");

    }

    //Enable the credit account field
    txtCreditAcc.setEnabled(true);

    // Enable the amount button
    txtPayAmount.setEnabled(true);

    //Enable the reference button
    txtPayReference.setEnabled(true);

    //Enable the debit account layout
    layDebitAccount.setEnabled(true);

}
请帮帮我,只要我受够了。谢谢

/**
 * Function to start the scan
 * @param view - The view object calling the function
 */
public void startScan(View view) {

    // Create the scanIntegrator
    IntentIntegrator scanIntegrator = new IntentIntegrator(this);

    // Start the integrator
    scanIntegrator.initiateScan();

    // Start the integrator
    AlertDialog alertDialog=scanIntegrator.initiateScan();

    if(alertDialog==null) {

        // Disable the credit account field
        txtCreditAcc.setEnabled(false);

        // disable the amount button
        txtPayAmount.setEnabled(false);

        //disable the reference button
        txtPayReference.setEnabled(false);

        //disable the debit account layout
        layDebitAccount.setEnabled(false);

    }

}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    // Store the scanning result
    IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);

    // Check if the result is null,
    if (scanningResult != null) {

        // get the scan content
        String scanContent = scanningResult.getContents();

        populateScanData(scanContent);


    } else {


        generalMethods.showToastMessage(context,"No scan data received!");

    }

    //Enable the credit account field
    txtCreditAcc.setEnabled(true);

    // Enable the amount button
    txtPayAmount.setEnabled(true);

    //Enable the reference button
    txtPayReference.setEnabled(true);

    //Enable the debit account layout
    layDebitAccount.setEnabled(true);

}