Fixed
Status Update
Comments
ka...@gmail.com <ka...@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request fromhttps://github.com/androidx/androidx/pull/141 .
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
https://android-review.googlesource.com/1649748
Branch: androidx-main
commit 57ca221882695bd6a52549f4d9ea3b812e6fe87c
Author: Simon Schiller <simonschiller@users.noreply.github.com>
Date: Mon Mar 22 16:09:30 2021
[GH] [FragmentStrictMode] Detect <fragment> tag usage
## Proposed Changes
- Detect `<fragment>` tag usage inside XML layouts
## Testing
Test: See `FragmentStrictModeTest#detectFragmentTagUsage`
## Issues Fixed
Fixes: 153738235
This is an imported pull request from
Resolves #141
Github-Pr-Head-Sha: 4ea052596e4341b9f11bcf335e2bc38045a91f19
GitOrigin-RevId: 62e7487aa4874eef6bb556490e193717cf937251
Change-Id: Iae48578e85e4e4897f806d7ade2e2a660adf9479
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_current.txt
M fragment/fragment/src/androidTest/java/androidx/fragment/app/strictmode/FragmentStrictModeTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentLayoutInflaterFactory.java
M fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentStrictMode.java
A fragment/fragment/src/main/java/androidx/fragment/app/strictmode/FragmentTagUsageViolation.java
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit 4776f596c08056c5e7234f3829de7698ad46296d
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon May 10 12:51:05 2021
Fix fragment result with parcelables
When using the fragment result API, if you put a parcelable into the
result bundle, your process dies, and your result listener attempts to
access the parcelable, you will get a class not found exception if you
do not set the classloader.
We should set the class loader on your bundle before returning the
listener callback to ensure the Parcelable classes are accesible.
RelNote: "You can now retrieve your Parcelable from the fragment result
bundle after process death."
Test: FragmentResultTest
Bug: 187443158
Change-Id: I6593233191347d9595f81268951d6f8dbb627273
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentResultTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
https://android-review.googlesource.com/1701765
Branch: androidx-main
commit 4776f596c08056c5e7234f3829de7698ad46296d
Author: Jeremy Woods <jbwoods@google.com>
Date: Mon May 10 12:51:05 2021
Fix fragment result with parcelables
When using the fragment result API, if you put a parcelable into the
result bundle, your process dies, and your result listener attempts to
access the parcelable, you will get a class not found exception if you
do not set the classloader.
We should set the class loader on your bundle before returning the
listener callback to ensure the Parcelable classes are accesible.
RelNote: "You can now retrieve your Parcelable from the fragment result
bundle after process death."
Test: FragmentResultTest
Bug: 187443158
Change-Id: I6593233191347d9595f81268951d6f8dbb627273
M fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentResultTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/FragmentManager.java
jb...@google.com <jb...@google.com> #4
This has been fixed internally and will be available in the Fragment 1.3.4
release via Fragment 1.4.0-alpha01
.
Description
Component used: Fragment Version used: 1.3.3 Devices/Android versions reproduced on: Emulator Android 10
Currently there is a crash trying to get parcelable from result after process restoration.
Setup:
MainActivity
,FirstFragment
andSecondFragment
.FirstFragment
toSecondFragment
.FirstFragment
callsgetParentFragmentManager().setFragmentResultListener()
inonViewCreated()
and listens for result.getParentFragmentManager().setResult()
on submit button click. Submit button does only that and doesn't navigate back toFirstFragment
.Bundle
viaputParcelable()
. We send backExampleClass
which implementsParcelable
using@kotlinx.parcelize.Parcelize
.Steps to reproduce:
SecondFragment
.FirstFragment
receives result inFragmentResultListener#onFragmentResult
and callsresult.getParcelable()
.android.os.BadParcelableException
There two ways to avoid crash:
result.setClassLoader(context.classLoader)
beforeresult.getParcelable()
.Is this something that should be fixed on Fragment or platform side?
What is the preferred workaround for the app developers in the meantime?