scanpay立即取消而不显示扫描视图

时间:2016-05-04 05:56:06

标签: android

这是我的代码:

public class MainActivity extends AppCompatActivity {

private int MY_SCAN_REQUEST_CODE = 100; // arbitrary int
Button btn;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    btn = (Button) findViewById(R.id.btn);

    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent scanActivity = new Intent(MainActivity.this, ScanPayActivity.class);
            scanActivity.putExtra(ScanPay.EXTRA_TOKEN, "MY_TOKEN");
            scanActivity.putExtra(ScanPay.EXTRA_SHOULD_SHOW_CONFIRMATION_VIEW, false);
            scanActivity.putExtra(ScanPay.EXTRA_SHOULD_SHOW_MANUAL_ENTRY_BUTTON, false);
            startActivityForResult(scanActivity, MY_SCAN_REQUEST_CODE);
        }
    });
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == MY_SCAN_REQUEST_CODE && resultCode == ScanPay.RESULT_SCAN_SUCCESS) {
        CreditCard creditCard = (CreditCard) data.getParcelableExtra(ScanPay.EXTRA_CREDIT_CARD);
        Toast.makeText(this, creditCard.number + " " + creditCard.month + "/" + creditCard.year + " " + creditCard.cvv, Toast.LENGTH_LONG).show();
    } else if (requestCode == MY_SCAN_REQUEST_CODE && resultCode == ScanPay.RESULT_SCAN_CANCEL) {
        Toast.makeText(this, "Scan cancel", Toast.LENGTH_LONG).show();
    } 
}}

我已按照此处提供的所有说明https://we.scanpay.it/integration 但是每当它被取消时仍然如此。无法理解为什么?请帮忙。

0 个答案:

没有答案