【发布时间】:2015-11-09 19:52:48
【问题描述】:
我正在尝试在我的应用程序中实现Card.io,我按照Card.io website 上的说明进行操作,当我进入我的应用程序并启动它时,它锁定在我的卡上,但之后没有其他任何反应。下面是我的代码
AndroidManifest
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<--!..........................-->
<activity android:name="io.card.payment.CardIOActivity" android:configChanges="keyboardHidden|orientation" android:hardwareAccelerated="true"/>
<activity android:name="io.card.payment.DataEntryActivity" android:screenOrientation="portrait"/>
活动结果
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == MY_SCAN_REQUEST_CODE) {
String cardNumbs, cardExp, cardCVV;
String resultStr;
if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) {
//TODO
CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);
cardNumbs = scanResult.getRedactedCardNumber();
acctDebitCardNo.setText(cardNumbs);
if (scanResult.isExpiryValid()) {
cardExp = scanResult.expiryMonth + "/" + "20" + scanResult.expiryYear;
acctDebitCardExp.setText(cardExp);
} else {
acctDebitCardExp.setError("Card Has Expired");
}
if (scanResult.cvv != null) {
cardCVV = scanResult.cvv;
acctDebitCardCvv.setText(cardCVV);
}
}
}
}
启动相机的权限
Intent scanIntent = new Intent(getActivity(), CardIOActivity.class);
// customize these values to suit our/there needs...LOL :).
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true);
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, true);
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);
// MY_SCAN_REQUEST_CODE is arbitrary and is only used within this activity.
startActivityForResult(scanIntent, MY_SCAN_REQUEST_CODE);
我不知道我做错了什么
【问题讨论】:
-
来自 card.io 的 Dave。请尝试各种卡。 card.io 仅限于识别带有大浮雕数字的传统格式信用卡。即使有这些,它也不是在所有情况下都能成功。
-
嗯,我已经在 5 种不同的卡上尝试过,但都没有成功(主要是万事达卡和维萨卡)。由于它不能正常工作,我们决定不使用它。
标签: android credit-card card.io