Fix returning result for SCAN intents

Set parameter for `com.google.zxing.client.android.SCAN`
intents so the result is returned instead of displayed.
This commit is contained in:
Markus Fisch
2019-11-16 13:00:57 +01:00
parent 325aa00bf8
commit 7416037762
2 changed files with 5 additions and 3 deletions
@@ -39,7 +39,6 @@ class CameraActivity : AppCompatActivity() {
private var preprocessor: Preprocessor? = null
private var invert = false
private var flash = false
private var returnResult = false
private var frontFacing = false
private var fallbackBuffer: IntArray? = null
@@ -114,7 +113,6 @@ class CameraActivity : AppCompatActivity() {
override fun onResume() {
super.onResume()
System.gc()
returnResult = "com.google.zxing.client.android.SCAN" == intent.action
if (hasCameraPermission(this, REQUEST_CAMERA)) {
openCamera()
}
@@ -25,6 +25,8 @@ class PickActivity : AppCompatActivity() {
private lateinit var cropImageView: CropImageView
private var returnResult = false
override fun onCreate(state: Bundle?) {
super.onCreate(state)
setContentView(R.layout.activity_pick)
@@ -37,6 +39,8 @@ class PickActivity : AppCompatActivity() {
setSystemAndToolBarTransparency(this@PickActivity)
}
returnResult = intent?.action == "com.google.zxing.client.android.SCAN"
val bitmap = if (
intent?.action == Intent.ACTION_SEND &&
intent.type?.startsWith("image/") == true
@@ -119,7 +123,7 @@ class PickActivity : AppCompatActivity() {
private fun scanImage(bitmap: Bitmap) {
val result = zxing.decodePositiveNegative(bitmap)
if (result != null) {
showResult(this, result)
showResult(this, result, returnResult)
finish()
return
}