Вот мои startActivityForResult()
:
val initialPosition = frame.tag as Int
val currentPosition = constraint.indexOfChild(frame)
Log.d(TAG, "initial position: $initialPosition") // prints initial position: 2
Log.d(TAG, "current position: $currentPosition") // prints current position: 2
val galleryIntent = Intent().apply {
type = "image/*"
action = Intent.ACTION_PICK
putExtra("initialPosition", initialPosition)
putExtra("currentPosition", currentPosition)
setResult(5)
}
startActivityForResult(Intent.createChooser(galleryIntent, "Pick image"), PICK_IMAGE_REQUEST_CODE)
Однако я не могу получить данные здесь:
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (resultCode == Activity.RESULT_OK){
Log.d(TAG, "ResultCode: $resultCode SUCCESS") // prints -1 SUCCESS
}
when (requestCode){
PICK_IMAGE_REQUEST_CODE -> {
Log.d(TAG, "${data?.getIntExtra("initialPosition", 0)}") // prints 0
Log.d(TAG, "${data?.extras?.getInt("initialPosition")}") // prints 0
Log.d(TAG, "${data?.extras?.getInt("currentPosition")}") // prints 0
}
}
super.onActivityResult(requestCode, resultCode, data)
}
Есть идеи почему?