我正在尝试在我的应用程序中实现 Card.io,我按照Card.io网站上的说明进行操作,当我进入我的应用程序并启动它时。当我单击按钮时,我调用 CardIOActivity 并且无法打开相机。单击按钮时出现此屏幕
这是我的清单代码:
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<application
android:label="card.io example"
android:theme="@style/MyTheme" >
<activity
android:name="MyScanActivity"
android:label="card.io example" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="io.card.payment.CardIOActivity"
android:configChanges="keyboardHidden|orientation"
android:hardwareAccelerated="true" />
<activity
android:name="io.card.payment.DataEntryActivity"
android:screenOrientation="portrait" />
</application>
这是我的java代码
public class MyScanActivity extends Activity {
final String TAG = getClass().getName();
private Button scanButton;
private TextView resultTextView;
private int MY_SCAN_REQUEST_CODE = 100;
@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();
if (CardIOActivity.canReadCardWithCamera()) {
scanButton.setText("Scan a credit card with card.io");
} else {
scanButton.setText("Enter credit card information");
}
}
public void onScanPress(View v) {
Intent scanIntent = new Intent(this, CardIOActivity.class);
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true);
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false);
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false);
scanIntent.putExtra(CardIOActivity.EXTRA_SUPPRESS_MANUAL_ENTRY, false);
scanIntent.putExtra(CardIOActivity.EXTRA_KEEP_APPLICATION_THEME, false);
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);
resultStr = "Card Number: " + scanResult.getRedactedCardNumber() + "\n";
if (scanResult.isExpiryValid()) {
resultStr += "Expiration Date: " + scanResult.expiryMonth + "/" + scanResult.expiryYear + "\n";
}
if (scanResult.cvv != null) {
resultStr += "CVV has " + scanResult.cvv.length() + " digits.\n";
}
if (scanResult.postalCode != null) {
resultStr += "Postal Code: " + scanResult.postalCode + "\n";
}
} else {
resultStr = "Scan was canceled.";
}
resultTextView.setText(resultStr);
}
}
我从来没有使用过card.io,我不知道出了什么问题。如何使用 Card.io 扫描我的签证或其他卡。如果有人知道解决方案,请帮助我。