My flow of activity is like this.
In Fragment
A, it allow user to capture image, and the image will be displayed on Activity B
for user to do some editing.
Fragment A
mImageListAdapter.mAddImageClickListener = object : ImageListAdapter.AddImageClickListener {
override fun addImageClicked() {
val options = arrayOf<CharSequence>("Take Photo", "Choose From Gallery", "Cancel")
val builder = android.support.v7.app.AlertDialog.Builder(activity)
builder.setTitle("Select Option")
builder.setItems(options) { dialog, item ->
if (options[item] == "Take Photo") {
dialog.dismiss()
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
startActivityForResult(intent, CAMERA_CAPTURE)
}
}
builder.show()
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
var bitmap: Bitmap? = null
if (requestCode == CAMERA_CAPTURE && resultCode == Activity.RESULT_OK) {
val extras = data?.extras
if (extras != null) {
bitmap = extras.get("data") as Bitmap
val intent = Intent(activity, ActivityB::class.java)
intent.putExtra("bitmap", bitmap)
startActivityForResult(intent, 12)
}
} else if (requestCode == 12 && resultCode == Activity.RESULT_OK) {
longToast("It get result from Activity B")
} else {
longToast("Nothing")
}
}
In Activity B,once the done button is clicked, the edited image suppose to be return to Fragment A, where I expect "It get result from Activity B
" will be displayed, but nothing get displayed!
Activity B
doneBtn.setOnClickListener {
image.buildDrawingCache()
val bitmap = image.getDrawingCache()
val resultIntent = Intent()
resultIntent.putExtra("bitmap", bitmap)
setResult(Activity.RESULT_OK, resultIntent)
finish()
}