2013-02-14 31 views
3

我正在使用Android应用程序通过信用卡进行支付,因为我正在使用CARD.IO SDK for android。显示此设备的Android card.io sdk无法使用相机读取卡号

我已经集成了card.io SDK在我的代码,但是当我启动它没有让我扫描任何card.It显示一条消息该设备无法使用相机来读取卡号应用

这里是我的代码:

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); 
    } 
} 

例外:

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

你正在使用什么设备? – 2013-02-14 19:00:08

+1

@ricintech,你是如何解决问题的? – 2013-04-29 13:25:21

回答

10

通常这种情况发生时,本机库是不是在项目的libs目录。结构应该如下所示,如果将sdk解压缩到项目目录中,将会发生这种情况。

$ 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 
+0

我添加了本地库,但我没有得到适当的解决方案,请帮助我。 – 2013-04-29 13:08:59

+0

从哪里可以得到car.io.jar? – MRX 2015-03-15 16:04:01