0

I use card.io sample code at my app, but scanning does not snapping the card, only focused on it. OnActivityResult does not get any data. What can help? Use Asus TF300t.

 public void onScanPress() {
    // This method is set up as an onClick handler in the layout xml
    // e.g. android:onClick="onScanPress"

    Intent scanIntent = new Intent(this, CardIOActivity.class);

    // customize these values to suit your needs.
    scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true); // default: true
    scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false); // default: false
    scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false); // default: false

    // hides the manual entry button
    // if set, developers should provide their own manual entry mechanism in the app
    scanIntent.putExtra(CardIOActivity.EXTRA_SUPPRESS_MANUAL_ENTRY, false); // default: false

    // matches the theme of your application
    scanIntent.putExtra(CardIOActivity.EXTRA_KEEP_APPLICATION_THEME, true); // default: false

    // MY_SCAN_REQUEST_CODE is arbitrary and is only used within this activity.
    startActivityForResult(scanIntent, MY_SCAN_REQUEST_CODE);
}

and onResult

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    String resultStr;
    if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) {
        CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);

        // Never log a raw card number. Avoid displaying it, but if necessary use getFormattedCardNumber()
        resultStr = "Card Number: " + scanResult.getRedactedCardNumber() + "\n";

        // Do something with the raw number, e.g.:
        // myService.setCardNumber( scanResult.cardNumber );

        if (scanResult.isExpiryValid()) {
            resultStr += "Expiration Date: " + scanResult.expiryMonth + "/" + scanResult.expiryYear + "\n";
        }

        if (scanResult.cvv != null) {
            // Never log or display a CVV
            resultStr += "CVV has " + scanResult.cvv.length() + " digits.\n";
        }

        if (scanResult.postalCode != null) {
            resultStr += "Postal Code: " + scanResult.postalCode + "\n";
        }
    }
    else {
        resultStr = "Scan was canceled.";
    }
   // resultTextView.setText(resultStr);

}

I use 4.0.0 aar, and I does not provide jniLibs (they must be at .aar, I suppose)

4

1 回答 1

0

onActivityResult 只有在卡片被识别、用户手动输入卡片或用户取消时才会被调用。正如@Govtart 解释的那样,并非所有卡片都可以识别。确保首先尝试示例应用程序

于 2015-01-30T18:22:40.107 回答