Below here sample code intent from camera :
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
startActivityForResult(intent, REQUEST_CAMERA)
Note: when I press back from camera as result on Activity result show like this:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=65537, result=0, data=null} to activity and Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null:
Try to come out solution like this :
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {
try {
when(resultCode){
Activity.RESULT_CANCELED -> {
System.out.println("nothing")
}
Activity.RESULT_OK -> {
if (requestCode == SELECT_FILE)
onSelectFromGalleryResult(data)
else if (requestCode == REQUEST_CAMERA)
onCaptureImageResult(data)
}
}
}catch (e:NullPointerException){
e.printStackTrace()
}
}
still not solve the problem because when i do debuging log it not come out on func onactivityresult if i go press go back from camera and not capture the image. Taking picture and pickup image from gallery work like charm.
Thank you. Please help me to solve this problem since along way solution given not working. It seem like google have to override fun onresultactivity(resultcode!!:Int) <- this one should have return non null.
data: Intent
as the param, but it should be nullable, so change it todata: Intent?
. – user1032613