我有一个你要扫描卡片的项目。对于此任务,我使用库card.io。最近我将库更新到最新版本(5.4.0)现在,不是扫描卡而是更改为手动输入。我做错了什么?所有设置均根据说明进行。
AndroidManifest
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="com.google.android.gallery3d.permission.GALLERY_PROVIDER" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<activity android:name="io.card.payment.CardIOActivity" android:configChanges="keyboardHidden|orientation" />
<activity android:name="io.card.payment.DataEntryActivity" />
<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" />
然后,我在这个类中尝试打开scanActivity(CardIOActivity)
private static void launchCardIoPhoto(Context ctx) {
if (!(ctx instanceof Activity)) return;
//Intent scanIntent = new Intent("android.media.action.IMAGE_CAPTURE");
Intent scanIntent = new Intent(ctx, CardIOActivity.class);
//scanIntent.putExtra(CardIOActivity.EXTRA_APP_TOKEN, CARD_IO_API_KEY);
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, false);
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false);
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false);
scanIntent.putExtra(CardIOActivity.EXTRA_SUPPRESS_MANUAL_ENTRY, true);
scanIntent.putExtra(CardIOActivity.EXTRA_USE_CARDIO_LOGO, true);
BankokApplication.app().ignoreNextResume();
Fragment fragment = ((Activity) ctx).getFragmentManager().findFragmentById(R.id.bottom_sheet_container);
if (fragment != null && fragment instanceof CardScanReceiver){
fragment.startActivityForResult(scanIntent, REQ_CODE_CARD_IO_PHOTO);
}else {
((Activity) ctx).startActivityForResult(scanIntent, REQ_CODE_CARD_IO_PHOTO);
}
}
从评论中更新:
经过测试
card.io中的示例应用程序按预期工作
修改
找错误:
No implementation found for boolean io.card.payment.CardScanner.nUseX86() (tried Java_io_card_payment_CardScanner_nUseX86 and Java_io_card_payment_CardScanner_nUseX86__)
Failed to load native library: No implementation found for boolean io.card.payment.CardScanner.nUseX86() (tried Java_io_card_payment_CardScanner_nUseX86 and Java_io_card_payment_CardScanner_nUseX86__)
答案 0 :(得分:0)
似乎card.io无法初始化设备摄像头并落入手动输入。
如果您的设备配有相机,检查相机是否未使用,并将其添加到您的清单(来自the documentation),以避免要求相机的不必要的功能:< / p>
<!-- 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" />
此外,如果您的设备运行Android 6并且用户拒绝了相机权限,则card.io将落入手动卡输入。
答案 1 :(得分:0)
修复问题。 该项目是删除库数据后,以前版本card.io的本机库。它正常工作。