Skip to content

Fix: Prevent ActivityResultLauncher crash by moving registration to onCreate#6655

Open
Kota-Jagadeesh wants to merge 2 commits intocommons-app:mainfrom
Kota-Jagadeesh:fix/crash-edit-cancel-upload
Open

Fix: Prevent ActivityResultLauncher crash by moving registration to onCreate#6655
Kota-Jagadeesh wants to merge 2 commits intocommons-app:mainfrom
Kota-Jagadeesh:fix/crash-edit-cancel-upload

Conversation

@Kota-Jagadeesh
Copy link
Collaborator

Description (required)

Fixes #6654

What changes did you make and why?
This PR fixes an IllegalStateException: Attempting to launch an unregistered ActivityResultLauncher crash. This crash occurs if a user selects multiple images for upload, deletes one of them during the media details step, and then tries to click the "Edit Image" button.

for fixing thhis, i moved the registerForActivityResult calls directly into the onCreate() method. This guaranteees the launchers are properly registered with the androidd system's lifecycle every time the fragment is created, preventing the crash

Tests performed (required)

Tested ProDebug on Redmi NOte 13 Pro with API level 35.

  • Selected 2 images for upload.
  • Deleted one image from the upload details screen.
  • Clicked the "Edit Image" button on the remaining image.
  • Verified that the Edit screen opens successfully without crashing.

Screenshots (for UI changes only)

a lifecycle crash fix.


Note: Please ensure that you have read CONTRIBUTING.md if this is your first pull request.

@RitikaPahwa4444
Copy link
Collaborator

Thanks @Kota-Jagadeesh, I'll test and review this PR by this weekend.

@github-actions
Copy link

✅ Generated APK variants!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Crash when editing an image after uploading two images and cancelling one

2 participants

Comments