时间:2021-05-20
ard.io开源的银行卡扫描的三方库真的是很好用啊。
首先需要在你的module的gradle的依赖文件中添加依赖
compile 'io.card:android-sdk:5.5.1'2 清单文件中加入如下Activity
<!-- Permission to vibrate - recommended, allows vibration feedback on scan --> <uses-permission android:name="android.permission.VIBRATE" /> <!-- Permission to use camera - required --> <uses-permission android:name="android.permission.CAMERA" /> <!-- Camera features - recommended --> <uses-feature android:name="android.hardware.camera" android:required="false" /> <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" /> <uses-feature android:name="android.hardware.camera.flash" android:required="false" /><activity android:name="io.card.payment.CardIOActivity" android:configChanges="keyboardHidden|orientation" /><activity android:name="io.card.payment.DataEntryActivity" />3 xml文件中
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.example.dell.scanbankdemo.MainActivity"> <Button android:id="@+id/btn_scan" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="扫描银行卡" /> <TextView android:id="@+id/tv_card_number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="银行卡号:" /></LinearLayout>全部代码:
public class MainActivity extends AppCompatActivity implements View.OnClickListener { public static final int MY_SCAN_REQUEST_CODE = 10; private Button mScanBtn; private TextView mNumberTv;//银行卡号 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mScanBtn = findViewById(R.id.btn_scan); mScanBtn.setOnClickListener(this); mNumberTv = findViewById(R.id.tv_card_number); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_scan: 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); break; } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == MY_SCAN_REQUEST_CODE) { String resultDisplayStr; 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() //resultDisplayStr = "银行卡号: " + scanResult.getRedactedCardNumber() + "\n"; //只显示尾号 resultDisplayStr = "银行卡号: " + scanResult.getFormattedCardNumber() + "\n"; //显示银行卡号 // Do something with the raw number, e.g.: // myService.setCardNumber( scanResult.cardNumber ); if (scanResult.isExpiryValid()) { resultDisplayStr += "有效期:" + scanResult.expiryMonth + "/" + scanResult.expiryYear + "\n"; } if (scanResult.cvv != null) { // Never log or display a CVV resultDisplayStr += "CVV has " + scanResult.cvv.length() + " digits.\n"; } if (scanResult.postalCode != null) { resultDisplayStr += "Postal Code: " + scanResult.postalCode + "\n"; } } else { resultDisplayStr = "Scan was canceled."; } mNumberTv.setText(resultDisplayStr); // do something with resultDisplayStr, maybe display it in a textView // resultTextView.setText(resultDisplayStr); } }}附上github地址
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
现在有好多扫描识别银行卡号的SDK都是收费的,但是也有不收费的,但是有一定的问题,就是那种印刷的银行卡号扫描不出来,希望哪位大神指导原因给解释下,这个不收费的S
微信公众号开通流量主需要填写银行卡号,但是想要更换银行卡,该怎么更换呢?下面我们就来看看微信公众号修改流量主银行卡号的教程。1、首先,我们进入微信公众号,下拉微
多说无益,贴代码:/***校验银行卡卡号**@paramcardId*@return*/publicstaticbooleancheckBankCard(Str
excel中输入银行卡号格式的方法如下: 1、常规情况下输入银行卡号。 2、会变成科学计数法,且最后面的自动变成0。 3、先输入英文单引号,再输入银行卡号
带上身份来证,到相应的银自行柜台进行补卡即可。是的,到发卡行进行补卡。银行卡丢失后,大部分银行都是可以补办原卡号银行卡的,不过有的银行不能补办,例如建设银行规定