π A high-performance Android SDK for reading Vietnamese π»π³ Citizen ID cards (CCCD) and credit cards via NFC technology π³. Built for enterprise-grade security and optimized native performance.
- β High-speed NFC reading capabilities
- π Enterprise-grade security protocols
- π± Optimized native performance
- π‘οΈ Advanced data protection
- π»π³ Full support for Vietnamese CCCD format
Support for all major credit card types with high-security standards:
Card Type | Status |
---|---|
π Visa | β Supported |
π¦ MasterCard | β Supported |
β¬ American Express | β Supported |
π₯ JCB | β Supported |
π§ Discover | β Supported |
π¨ UnionPay | β Supported |
Component | Specification |
---|---|
π± Android Version | API 21+ (Android 5.0+) |
π‘ Hardware | NFC capability required |
π» Language | Kotlin 1.9.x or higher |
ποΈ Gradle | 7.0+ recommended |
Add to your module's build.gradle
:
dependencies {
implementation 'com.yourcompany:android-card-reader:1.0.0'
}
<dependency>
<groupId>com.yourcompany</groupId>
<artifactId>android-card-reader</artifactId>
<version>1.0.0</version>
</dependency>
Add required permissions to your AndroidManifest.xml
:
<uses-permission android:name="android.permission.NFC" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
class MainActivity : AppCompatActivity() {
private lateinit var cardReader: CardReader
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Initialize the card reader
cardReader = CardReader.Builder(this)
.setDebugMode(BuildConfig.DEBUG)
.setSecurityLevel(SecurityLevel.HIGH)
.build()
}
}
class IdCardReader {
private val reader = CardReader.getInstance()
suspend fun readIdCard(): Result<IdCardData> {
return try {
val cardData = reader.readVietnamIdCard()
Result.success(cardData)
} catch (e: NfcException) {
Result.failure(e)
} catch (e: SecurityException) {
Result.failure(e)
}
}
// Callback-based approach
fun readIdCard(callback: (Result<IdCardData>) -> Unit) {
reader.readVietnamIdCard(object : CardReadCallback<IdCardData> {
override fun onSuccess(data: IdCardData) {
callback(Result.success(data))
}
override fun onError(error: Exception) {
callback(Result.failure(error))
}
})
}
}
class CreditCardProcessor {
private val reader = CreditCardReader.getInstance()
fun processCard(onResult: (CardResult) -> Unit) {
reader.readCreditCard(object : CreditCardCallback {
override fun onCardDetected(cardInfo: CardInfo) {
onResult(CardResult.Success(
cardType = cardInfo.type,
maskedNumber = cardInfo.maskedPan,
expiryDate = cardInfo.expiryDate
))
}
override fun onError(error: CardReadError) {
onResult(CardResult.Error(error.message))
}
override fun onTimeout() {
onResult(CardResult.Timeout)
}
})
}
}
data class IdCardData(
val id: String,
val fullName: String,
val dateOfBirth: String,
val gender: String,
val nationality: String,
val placeOfOrigin: String,
val placeOfResidence: String,
val identifyingFeatures: String?,
val issueDate: String,
val expiryDate: String,
val photo: ByteArray?
)
data class CardInfo(
val type: CardType,
val maskedPan: String,
val expiryDate: String?,
val cardholderName: String?
)
sealed class CardResult {
data class Success(
val cardType: CardType,
val maskedNumber: String,
val expiryDate: String?
) : CardResult()
data class Error(val message: String) : CardResult()
object Timeout : CardResult()
}
- π‘οΈ End-to-end encryption for sensitive data
- π Secure key management system
- π Certificate-based authentication
- π¦ Encrypted local storage
- π« PCI DSS compliance for credit cards
- π‘οΈ Anti-tampering protection
val securityConfig = SecurityConfig.Builder()
.setEncryptionLevel(EncryptionLevel.AES_256)
.setKeyStorageType(KeyStorageType.ANDROID_KEYSTORE)
.setCertificateValidation(true)
.build()
CardReader.configure(securityConfig)
val nfcConfig = NfcConfig.Builder()
.setReadTimeout(10000) // 10 seconds
.setRetryCount(3)
.setTagLostRetryDelay(1000)
.build()
CardReader.setNfcConfig(nfcConfig)
- β‘ Card reading speed: < 2 seconds
- π Success rate: 99.9%
- π Concurrent operations: Single-threaded for NFC safety
- π Battery optimization: Automatic NFC power management
@Test
fun testCardReading() {
val mockReader = MockCardReader()
val result = mockReader.readTestCard()
assertTrue(result.isSuccess)
assertEquals("123456789", result.getOrNull()?.id)
}
Check the /sample
directory for complete integration examples.
Comprehensive documentation available at:
- π API Reference
- π Integration Guide
- π Sample Project
- π± Best Practices
NFC not working:
if (!NfcAdapter.getDefaultAdapter(this).isEnabled) {
// Prompt user to enable NFC
startActivity(Intent(Settings.ACTION_NFC_SETTINGS))
}
Card reading timeout:
// Increase timeout for slower cards
CardReader.setReadTimeout(15000) // 15 seconds
- π§ Technical Support: [email protected]
- π¬ Developer Community: Join Discord
- π Issues & Bug Reports: GitHub Issues
- π Stack Overflow: Tag
android-card-reader
MIT License
Copyright (c) 2024 Your Company
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Ready to integrate? Check out our Quick Start Guide or explore the Sample App to see the SDK in action!