Skip to content

Latest commit

 

History

History
56 lines (42 loc) · 1.65 KB

README.md

File metadata and controls

56 lines (42 loc) · 1.65 KB

This Library will help you to implement scan the card(Credit Card, Debit Card) details. It will help you to save your time and mistakes.

Set Up

1. Add it in your project level build.gradle at the end of repositories:

allprojects {
		repositories {
			maven { url 'https://jitpack.io' }
		}
	}

2. Add the dependency:

dependencies {
          implementation 'com.github.hiteshsarsava:cardscanner:${latestVersion}' //e.g., v0.0.1
  }

latestVersion :

How to use it

1. Prepare activity result:

private val resultLauncher =
      registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
          if (result.resultCode == Activity.RESULT_OK) {
              // There are no request codes
              val data: Intent = result.data ?: return@registerForActivityResult
              val cardDetails: CardDetails =
                  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
                      data.getSerializableExtra(
                          ScannerActivity.CARD_DETAILS,
                          CardDetails::class.java
                      ) as CardDetails
                  } else {
                      data.getSerializableExtra(ScannerActivity.CARD_DETAILS) as CardDetails
                  }
              setCardData(cardDetails)
          }
      }
      

2. Launch Activity:

resultLauncher.launch(Intent(this@MainActivity, ScannerActivity::class.java))