2016-07-19 79 views

回答

0

在您的活動或片段您在使用startActivityForResult像開始Card.io活動:

private int CARD_SCAN_REQUEST_CODE = 1; 
Intent scanIntent = new Intent(activity, CardIOActivity.class); 

scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false); 
scanIntent.putExtra(CardIOActivity.EXTRA_SUPPRESS_MANUAL_ENTRY, true); 
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true); 
scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, true); 

startActivityForResult(scanIntent, CARD_SCAN_REQUEST_CODE); 

,然後你得到像在onActivityResult響應:

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

    if (requestCode == CARD_SCAN_REQUEST_CODE) { 

     if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) 
     { 
      CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT); 
      //TODO: get data from scanResult 
     } 
    } 
} 
+0

我已經完成了代碼,就像你說的,但沒有得到掃描結果 –

+0

你在哪裏放這個代碼,活動或片段? –

+0

我將我的代碼放入活動 –

相關問題