这显示Android的设备SDK card.io不能使用相机来读取卡号 [英] Android card.io sdk showing this device can not use camera to read card numbers

查看:1594
本文介绍了这显示Android的设备SDK card.io不能使用相机来读取卡号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个Android应用程序便于支付通过信用卡,我现在用的 CARD.IO SDK 为Android。

我已经集成了card.io SDK在我的code,但是当我启动应用程序这不是让我扫描显示消息的任何card.It 此设备不能使用相机来读取卡号

下面是我的code:

包org.my.scanExample;

 进口io.card.payment.CardIOActivity;
进口io.card.payment.CreditCard;
进口org.my.scanExample.R;
进口android.app.Activity;
进口android.content.Intent;
进口android.os.Bundle;
进口android.view.View;
进口android.widget.Button;
进口android.widget.TextView;公共类MyScanActivity扩展活动
{
    //您必须card.io登记,以获得一个应用程序标记。转到https://card.io/apps/new/
    私有静态最后弦乐MY_CARDIO_APP_TOKEN =APP_ID;
    私人视图V;
    最后的字符串标记=的getClass()的getName()。    私人按钮scanButton;
    私人TextView的resultTextView;    私人诠释MY_SCAN_REQUEST_ code = 100; //任意INT    / **当第一次创建活动调用。 * /
    @覆盖
    公共无效的onCreate(捆绑savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);        resultTextView =(的TextView)findViewById(R.id.resultTextView);
        scanButton =(按钮)findViewById(R.id.scanButton);
    }    @覆盖
    保护无效onResume(){
        super.onResume();        resultTextView.setText(card.io库版本:+ CardIOActivity.sdkVersion()+\\ nBuilt:+ CardIOActivity.sdkBuildDate());        如果(CardIOActivity.canReadCardWithCamera(本)){
            scanButton.setText(扫描的信用卡card.io);
        }
        其他{
            scanButton.setText(输入信用卡信息);
            开启扫描preSS(V);
        }
    }    公共无效开启扫描preSS(视图v){
        //此方法设置为在布局XML一个onClick处理程序
        //例如安卓的onClick =开启扫描preSS        意图scanIntent =新意图(这一点,CardIOActivity.class);        //需要与card.io认证
        scanIntent.putExtra(CardIOActivity.EXTRA_APP_TOKEN,MY_CARDIO_APP_TOKEN);        //自定义这些值以满足您的需求。
        scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY,真); //默认值:true
        scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV,FALSE); //默认值:false
        scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_ZIP,FALSE); //默认值:false        //隐藏手动输入按钮
        //如果设置,开发人员应该提供自己手工输入机制的应用
        scanIntent.putExtra(CardIOActivity.EXTRA_SUP preSS_MANUAL_ENTRY,FALSE); //默认值:false        // MY_SCAN_REQUEST_ code是任意的,只是这个活动中使用。
        startActivityForResult(scanIntent,MY_SCAN_REQUEST_ code);
    }    @覆盖
    保护无效的onActivityResult(INT申请code,INT结果code,意图数据){
        super.onActivityResult(要求code,结果code,数据);        串resultStr;
        如果(数据= NULL&放大器;!&安培; data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)){
            信用卡式scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);            //从不记录原始卡号。避免显示出来,但如果需要使用getFormattedCardNumber()
            resultStr =卡号:+ scanResult.getRedactedCardNumber()+\\ n;            //做一些与原始的数字,例如:
            // myService.setCardNumber(scanResult.cardNumber);            如果(scanResult.isExpiryValid()){
                resultStr + =到期日期:+ scanResult.expiryMonth +/+ scanResult.expiryYear +\\ n;
            }            如果(scanResult.cvv!= NULL){
                //从不记录或显示CVV
                resultStr + =CVV有+ scanResult.cvv.length()+数字\\ n;
            }            如果(scanResult.zip!= NULL){
                resultStr + =邮编+ scanResult.zip +\\ n;
            }
        }
        其他{
            resultStr =扫描被取消了。
        }
        resultTextView.setText(resultStr);
    }
}

例外:

 无法加载本地库:无法加载cardIODecider:indLibrary返回null。
-processor类型不受支持
cardIoScanErrorNoDeviceSupport


解决方案

这通常发生在本机库不在项目的libs目录。其结构应如下所示,如果你解压缩SDK到你的项目目录,这将发生。

  $ LS库/ *
库/ card.io.jar库/ armeabi:
libcardioDecider.so库/ armeabi-V7A:
libcardioDecider.so libcardioRecognizer.so libcardioRecognizer_tegra2.so libopencv_core.so libopencv_imgproc.so库/ MIPS:
libcardioDecider.so库/ 86:
libcardioDecider.so

I am working on an android app which facilitate payment through credit card for that I am using CARD.IO SDK for android.

I have integrated the card.io sdk in my code but when I launch the app it's not allowing me to scan any card.It showing a message this device can not use camera to read card numbers

Here is my code:

package org.my.scanExample;

import io.card.payment.CardIOActivity;
import io.card.payment.CreditCard;
import org.my.scanExample.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MyScanActivity extends Activity
{
    // You MUST register with card.io to get an app token. Go to https://card.io/apps/new/
    private static final String MY_CARDIO_APP_TOKEN = "app_id";
    private View v;
    final String TAG = getClass().getName();

    private Button scanButton;
    private TextView resultTextView;

    private int MY_SCAN_REQUEST_CODE = 100; // arbitrary int

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        resultTextView = (TextView)findViewById(R.id.resultTextView);
        scanButton = (Button)findViewById(R.id.scanButton);
    }

    @Override
    protected void onResume() {
        super.onResume();

        resultTextView.setText("card.io library version: " + CardIOActivity.sdkVersion() + "\nBuilt: " + CardIOActivity.sdkBuildDate());

        if (CardIOActivity.canReadCardWithCamera(this)) {
            scanButton.setText("Scan a credit card with card.io");
        }
        else {
            scanButton.setText("Enter credit card information");
            onScanPress(v);
        }
    }

    public void onScanPress(View v) {
        // This method is set up as an onClick handler in the layout xml
        // e.g. android:onClick="onScanPress"

        Intent scanIntent = new Intent(this, CardIOActivity.class);

        // required for authentication with card.io
        scanIntent.putExtra(CardIOActivity.EXTRA_APP_TOKEN, MY_CARDIO_APP_TOKEN);

        // customize these values to suit your needs.
        scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true); // default: true
        scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false); // default: false
        scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_ZIP, 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

        // MY_SCAN_REQUEST_CODE is arbitrary and is only used within this activity.
        startActivityForResult(scanIntent, MY_SCAN_REQUEST_CODE);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        String resultStr;
        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()
            resultStr = "Card Number: " + scanResult.getRedactedCardNumber() + "\n";

            // Do something with the raw number, e.g.:
            // myService.setCardNumber( scanResult.cardNumber );

            if (scanResult.isExpiryValid()) {
                resultStr += "Expiration Date: " + scanResult.expiryMonth + "/" + scanResult.expiryYear + "\n"; 
            }

            if (scanResult.cvv != null) { 
                // Never log or display a CVV
                resultStr += "CVV has " + scanResult.cvv.length() + " digits.\n";
            }

            if (scanResult.zip != null) {
                resultStr += "Zip: " + scanResult.zip + "\n";
            }
        }
        else {
            resultStr = "Scan was canceled.";
        }
        resultTextView.setText(resultStr);
    }
}

Exception:

Failed to load native library: couldn't load cardIODecider : indLibrary returned null.
-processor type is not supported 
cardIoScanErrorNoDeviceSupport

解决方案

Typically this happens when the native libraries are not in the project's libs directory. The structure should look as follows, which will happen if you unzip the sdk into your project's directory.

$ ls libs/*
libs/card.io.jar

libs/armeabi:
libcardioDecider.so

libs/armeabi-v7a:
libcardioDecider.so     libcardioRecognizer.so      libcardioRecognizer_tegra2.so   libopencv_core.so       libopencv_imgproc.so

libs/mips:
libcardioDecider.so

libs/x86:
libcardioDecider.so

这篇关于这显示Android的设备SDK card.io不能使用相机来读取卡号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆