Closed alan-converge closed 2 years ago
Sorry, I know how frustrating this is 🙈 I've updated the README with the new, recommended way for AndroiX Activities:
class YourActivity : Activity() {
private val resultLauncher = registerForActivityResult(StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
val scan = result.data?.getStringExtra("SCAN_RESULT")
// do something with "scan"
}
}
fun openScanner() {
resultLauncher.launch(Intent("com.google.zxing.client.android.SCAN"))
}
}
There is a basic training is available at developer.android.com.
Markus, I'm new to Kotlin and cannot replace the deprecated startActivityForResult with the new Activity.startActivityForResult. I've spent a few hours following online guides. No luck. Please refactor the snippet in the README.