我正在开发使用card.io library扫描借记卡和信用卡的应用程序。我的应用程序只扫描包含刻数的卡。但我需要扫描所有类型的卡。请建议我扫描所有类型的卡
答案 0 :(得分:0)
在您的活动或片段中,您必须使用startActivityForResult
启动Card.io活动,如:
private int CARD_SCAN_REQUEST_CODE = 1;
Intent scanIntent = new Intent(activity, CardIOActivity.class);
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false);
scanIntent.putExtra(CardIOActivity.EXTRA_SUPPRESS_MANUAL_ENTRY, true);
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true);
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, true);
startActivityForResult(scanIntent, CARD_SCAN_REQUEST_CODE);
然后你会在onActivityResult
中得到答案,如:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CARD_SCAN_REQUEST_CODE) {
if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT))
{
CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);
//TODO: get data from scanResult
}
}
}