QRSender/app/src/main/java/com/zervonetwork/qrsender/QRCodeScanner.kt
2023-09-24 19:10:53 +02:00

23 lines
No EOL
698 B
Kotlin

import android.app.Activity
import android.content.Intent
import com.journeyapps.barcodescanner.CaptureActivity
class QRCodeScanner {
fun initiateScan(activity: Activity) {
val intent = Intent(activity, CaptureActivity::class.java)
activity.startActivityForResult(intent, SCAN_REQUEST_CODE)
}
fun handleActivityResult(requestCode: Int, resultCode: Int, data: Intent?): String? {
if (requestCode == SCAN_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
val result = data?.getStringExtra("SCAN_RESULT")
return result
}
return null
}
companion object {
private const val SCAN_REQUEST_CODE = 123
}
}