Skip to content

Instantly share code, notes, and snippets.

@erdalkaymak
Created January 25, 2021 11:01
Show Gist options
  • Select an option

  • Save erdalkaymak/ab7d4a6760d38805bf817abdd0bb67ee to your computer and use it in GitHub Desktop.

Select an option

Save erdalkaymak/ab7d4a6760d38805bf817abdd0bb67ee to your computer and use it in GitHub Desktop.
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == 100) {
if (resultCode == Activity.RESULT_OK) {
selectedImageBitmap = data?.extras?.get("data") as Bitmap
selected_img.setImageBitmap(selectedImageBitmap)
performTextRecognitionOnDevice(selectedImageBitmap!!)
} else {
if (data != null) {
MediaStore.Images.Media.getBitmap(
this.contentResolver,
data.data
)
}
}
}
if (requestCode == 200) {
if (resultCode == Activity.RESULT_OK) {
val pickedImage: Uri? = data?.data
try {
selectedImageBitmap = MediaStore.Images.Media.getBitmap(this.contentResolver, pickedImage)
selected_img.setImageBitmap(selectedImageBitmap)
performTextRecognitionOnDevice(selectedImageBitmap!!)
} catch (e: IOException) {
e.printStackTrace()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment