您好,登錄后才能下訂單哦!
這篇文章主要介紹了Android如何實現銀行卡號掃描識別功能,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
首先導入依賴:compile 'io.card:android-sdk:5.5.1'
然后在你需要調用拍照的地方加上一下:
Intent scanIntent = new Intent(this, CardIOActivity.class); // customize these values to suit your needs. scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true); // default: false scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false); // default: false scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false); // default: false // MY_SCAN_REQUEST_CODE is arbitrary and is only used within this activity. startActivityForResult(scanIntent, MY_SCAN_REQUEST_CODE);
在onActivityForResult中接收結果:
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == MY_SCAN_REQUEST_CODE) { String result; 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() result = "Card Number: " + scanResult.getRedactedCardNumber() + "\n"; if (scanResult.isExpiryValid()) { result += "Expiration Date: " + scanResult.expiryMonth + "/" + scanResult.expiryYear + "\n"; } if (scanResult.cvv != null) { // Never log or display a CVV result += "CVV has " + scanResult.cvv.length() + " digits.\n"; } if (scanResult.postalCode != null) { result += "Postal Code: " + scanResult.postalCode + "\n"; } } else { result = "Scan was canceled."; } Log.e("resultdispalyStr----",result); } }
感謝你能夠認真閱讀完這篇文章,希望小編分享的“Android如何實現銀行卡號掃描識別功能”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。