Status Update
Comments
b9...@gmail.com <b9...@gmail.com> #2
je...@google.com <je...@google.com>
il...@google.com <il...@google.com> #3
Camera apps are not required to deliver a thumbnail, that is correct as per the
Note: When you use
ACTION_IMAGE_CAPTURE
to capture a photo, the camera may also return a downscaled copy (a thumbnail) of the photo in the resultIntent
, saved as aBitmap
in an extra field named"data"
.
We can update the documentation to make this more clear.
b9...@gmail.com <b9...@gmail.com> #4
#3 That's the context of TakePicturePreview()
not TakePicture()
. The later use MediaStore.EXTRA_OUTPUT
from client side and save whole picture instead of preview to the Uri destination we provide.
al...@gmail.com <al...@gmail.com> #5
#3 I find it problematic if it does not return a thumbnail. I already created an uri for the image, what if user decides not to take a photo in the camera? I would need to do extra work to find out whether the uri has been written to..
ap...@google.com <ap...@google.com> #6
Branch: androidx-master-dev
commit 8dba38c1762e31c606fcc9a924549da933465e59
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Apr 30 17:37:00 2020
Adjust the TakePicture() docs
The TakePicture ActivityResultContract uses the
MediaStore.ACTION_IMAGE_CAPTURE intent action which does not guarantee a
thumbnail will be returned. We should specify that in the TakePicture
docs
Test: ./gradlew bOS
Bug: 154302879
Change-Id: I42caaae32380c172f7e4ff6b0ec5db6c2eaa7ab4
M activity/activity/src/main/java/androidx/activity/result/contract/ActivityResultContracts.java
al...@gmail.com <al...@gmail.com> #7
This makes the contract useless because the result is always null. Can there be at least some indications of success please?
il...@google.com <il...@google.com> #8
The result is not always null - that'll depend on what Camera app is handling the ACTION_IMAGE_CAPTURE
- camera apps absolutely can both save the output and provide a thumbnail Bitmap.
That being said, I agree that the role of the provided contracts is to cover the most common behavior - which in this case would mean returning a boolean result rather than the thumbnail.
As a short term workaround until the next release, you can create your own
ap...@google.com <ap...@google.com> #9
Branch: androidx-master-dev
commit 5277ad9de4c6cdc4d5d4a5808644b8e019ce5925
Author: Ian Lake <ilake@google.com>
Date: Fri May 01 11:25:24 2020
Change TakePicture to return a boolean result
The primary use case for using the TakePicture
contract is to save an image to a given Uri
therefore the return type should reflect this
by using a boolean result, avoiding the need
to distinguish between a null result due to
the user cancelling taking a picture and a
null result due to the Camera app not also
returning a thumbnail Bitmap.
Test: updated activity testapp
BUG: 154302879
Change-Id: I46caa5bc865473f083dfd95013cad661296c0029
M activity/activity/api/1.2.0-alpha05.txt
M activity/activity/api/current.txt
M activity/activity/api/public_plus_experimental_1.2.0-alpha05.txt
M activity/activity/api/public_plus_experimental_current.txt
M activity/activity/api/restricted_1.2.0-alpha05.txt
M activity/activity/api/restricted_current.txt
M activity/activity/src/main/java/androidx/activity/result/contract/ActivityResultContracts.java
M activity/integration-tests/testapp/src/main/AndroidManifest.xml
M activity/integration-tests/testapp/src/main/java/androidx/activity/integration/testapp/MainActivity.kt
A activity/integration-tests/testapp/src/main/res/xml/file_paths.xml
il...@google.com <il...@google.com> #10
We've updated the TakePicture
contract to return a boolean indicating success or not. This will be available in Activity 1.2.0-alpha05.
b9...@gmail.com <b9...@gmail.com> #11
Great! Thanks.
al...@gmail.com <al...@gmail.com> #12
Thanks!
Description
I am using the following code to take a picture and upload. During this process, I will need a thumbnail for preview. I am using
androidx.activity:activity-ktx:1.2.0-alpha03
andandroidx.fragment:fragment-ktx:1.3.0-alpha03
, tested on Pixel 2 Xl API 29 on emulator.The code in invoked by a view, which is owned by a fragment(
caller
), which is owned by an activityThe current result is that
ActivityResultContracts.TakePicture()
always return null, but images are correctly saved into the provided uri... I also found out thatintent
doesn't seem to have any extras when it returns.Please let me know if you need any information. Thanks in advanced!