Questions tagged [activityresultcontracts]
25 questions
8
votes
4 answers
How to construct PickVisualMediaRequest for ActivityResultLauncher
I am trying to use the Activity Result APIs to handle the picking of a single photo for an app I am developing. I am trying to use one of the predefined contracts to keep things simple. So, I am attempting to use the…

David Read
- 1,089
- 1
- 9
- 23
4
votes
1 answer
READ_EXTERNAL_STORAGE is always denied on Android 13 device
My application targets api level 32. When running on Android 13 device, ActivityResultContracts.RequestMultiplePermissions() always returns PERMISSION_DENIED even if the user presses on "Allow".
Also, when checking in settings->app->permissions, the…

Omar Assidi
- 41
- 3
3
votes
6 answers
Android: How to differentiate between multiple intents when using ActivityResultLauncher
I am creating a Intent chooser to choose between a the phone camera app and the gallery/file manager.
Intent chooserIntent = Intent.createChooser(clickPhoto(),"Set Image Using");
…

Pemba Tamang
- 1,235
- 16
- 38
2
votes
0 answers
Android Photo Picker set tick for already selected uri's previously
Reference to the feature -> https://developer.android.com/training/data-storage/shared/photopicker#device-availability
Code and explanation I
I create a request which will open up photo and video picker, after selecting a list of uri's is returned…

WuzerHaun
- 35
- 5
2
votes
0 answers
Attempting to launch an unregistered ActivityResultLauncher crash
I have registered launcher before activity get started but some times when launch is called on listener it gets crashed and reason is mentioned below
Sometimes I am getting this:
java.lang.IllegalStateException: Attempting to launch an unregistered…

vikas jain
- 31
- 3
2
votes
0 answers
ActivityResultContracts.CaptureVideo() crashing with DeadObjectExceptions on API 33?
I'm trying to use ActivityResultContracts.CaptureVideo(), but when I run it on API 33, it's crashing with this stacktrace:
> 2022-09-19 20:32:02.047 577-601/system_process W/WindowManager: Exception thrown during dispatchAppVisibility…

Dwebtron
- 777
- 13
- 27
2
votes
1 answer
Select and extract contact details using Intent and ActivityResultContracts
I have a button to open and select a contact for some of it's specific data - name and number using ActivityResultContracts.PickContact. Using the guide from this page and some modifications, I was able to retrieve the contact name successfully.
I…

Kinyo356
- 135
- 13
1
vote
0 answers
ActivityResultContracts.TakePicture with front camera
I'm using ActivityResultContracts to capture images, is there any way by which I can launch my front camera by default?
As per the documentation it is possible to pass extra data by overriding createIntent method, can I use that here?
It seems to be…

Sreehari K
- 887
- 6
- 16
1
vote
1 answer
How to view media files in App-specific storage with default android gallery
How can I open the default Android Gallery to display some images that I store in my Application's internal storage folder for example data.com.myapp.appname.files.images?
I have tried a couple of ActivityResultContract but I either get a file…

RandomType
- 47
- 1
- 8
1
vote
0 answers
How to get the Uri of the video captured with registerForActivityResult() in android?
I am trying to capture a video through the camera in my application, I am using registerForActivityResult() because startActivityForResult() has been deprecated. I am passing the ActivityResultContracts.CaptureVideo() as a contract in the…

Samarthya Bararia
- 11
- 2
1
vote
1 answer
getting back a result from LauncherForActivityResult
I'm a bit stuck in a function I'm writing.
I have a function that calls another app I wrote and needs to return a Boolean
@Composable
fun callApp(
//someparams
) : Boolean {
//some code
}
after some logic, i launch my application via:
val…

Anon
- 502
- 5
- 19
1
vote
1 answer
How safe is registering contracts with ActivityResultRegistry after onResume in android?
The following code gives me error as registering occurs after onResume:
class TempActivity: AppCompatActivity(){
private lateinit var binding: ActivityTempBinding
override fun onCreate(savedInstanceState: Bundle?) {
…

Diken Mhrz
- 327
- 2
- 14
1
vote
0 answers
Can't Read phone number from content Provider query
I used start activity with intent for select contact and receive data from onActivityResult method. onActivityResult method is deprecated and have to use registerForActivityResult solution.
Before:
val intent = Intent(Intent.ACTION_PICK).apply {
…

Ali Elahi
- 131
- 1
- 10
1
vote
1 answer
How To Send Intent Back using ActivityLauncher API?
I've been using this method to try to send data between Activities, but Google don't show you how to send the data back from the other Activity. So I started looking for other methods that might work, and the only thing I could find was…

Skello
- 333
- 2
- 15
1
vote
1 answer
How to limit ActivityResultContract.GetContent to media (image or video)
Is there a way to make ActivityResultContract.GetContent filter only media files?
private val selectMediaResultLauncher = registerForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? ->
// Do something with the uri
}
Tried to…

Udi Oshi
- 6,787
- 7
- 47
- 65