Fixed
Status Update
Comments
il...@google.com <il...@google.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
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 0ae36378b0381b8da2746fbac9c6bf8f837c495d
Author: Jeremy Woods <jbwoods@google.com>
Date: Fri Jul 17 02:10:30 2020
Ensure ActivityResultLauncher can be launched in onCreate
When attempting to launch an ActivityResultLauncher in onCreate() of a
Fragment, it fails since the the Fragment's Lifecycle does not move to
CREATED until after the onCreate() callback in executed. We should
register the callback as soon as the fragment is attached since that is
the point at which we have all of the needed information.
This change also adds tests to verify that ComponentActivity does not
suffer from the same issue.
Test: Added Activity and Fragment tests
Bug: 161464278
RelNote: "You can now call launch() on an ActivityResultLauncher in the
onCreate() lifecycle method of a fragment."
Change-Id: Ifd98f308fdfbd7c9ce3ae93d032b140d6f3ec35e
M activity/activity/src/androidTest/AndroidManifest.xml
A activity/activity/src/androidTest/java/androidx/activity/ComponentActivityResultTest.kt
M fragment/fragment/api/1.3.0-alpha07.txt
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_1.3.0-alpha07.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_1.3.0-alpha07.txt
M fragment/fragment/api/restricted_current.txt
A fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentActivityResultTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
https://android-review.googlesource.com/1365186
Branch: androidx-master-dev
commit 0ae36378b0381b8da2746fbac9c6bf8f837c495d
Author: Jeremy Woods <jbwoods@google.com>
Date: Fri Jul 17 02:10:30 2020
Ensure ActivityResultLauncher can be launched in onCreate
When attempting to launch an ActivityResultLauncher in onCreate() of a
Fragment, it fails since the the Fragment's Lifecycle does not move to
CREATED until after the onCreate() callback in executed. We should
register the callback as soon as the fragment is attached since that is
the point at which we have all of the needed information.
This change also adds tests to verify that ComponentActivity does not
suffer from the same issue.
Test: Added Activity and Fragment tests
Bug: 161464278
RelNote: "You can now call launch() on an ActivityResultLauncher in the
onCreate() lifecycle method of a fragment."
Change-Id: Ifd98f308fdfbd7c9ce3ae93d032b140d6f3ec35e
M activity/activity/src/androidTest/AndroidManifest.xml
A activity/activity/src/androidTest/java/androidx/activity/ComponentActivityResultTest.kt
M fragment/fragment/api/1.3.0-alpha07.txt
M fragment/fragment/api/current.txt
M fragment/fragment/api/public_plus_experimental_1.3.0-alpha07.txt
M fragment/fragment/api/public_plus_experimental_current.txt
M fragment/fragment/api/restricted_1.3.0-alpha07.txt
M fragment/fragment/api/restricted_current.txt
A fragment/fragment/src/androidTest/java/androidx/fragment/app/FragmentActivityResultTest.kt
M fragment/fragment/src/main/java/androidx/fragment/app/Fragment.java
jb...@google.com <jb...@google.com> #4
This has been fixed internally and will be available in the Fragment 1.3.0-alpha08 release.
va...@gmail.com <va...@gmail.com> #5
Have the same issue on version 1.5.4
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
checkPermission(Permission.NOTIFICATION, R.string.notification_permission_not_granted)
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
checkPermission(Permission.NOTIFICATION, R.string.notification_permission_not_granted)
}
}
jb...@google.com <jb...@google.com> #6
@ #5: Please upload a new issue with a minimal sample project that reproduces this issue using the latest version of Activity and Fragment.
pa...@wagwalking.com <pa...@wagwalking.com> #7
This is still happening!
Description
Version used: 1.3.0-alpha06
STEPS TO REPRODUCE
1. Try calling ActivityResultLauncher.launch() during Fragment.onCreate()
RESULTS
Actual: Exception is thrown because fragment is not in created state. Exception is included below.
Expected: No exception is thrown.
NOTES
I called super.onCreate() first. The issue seems to be that the ActivityResultLauncher is looking at the lifecycle to be set to CREATED.
java.lang.IllegalStateException: Operation cannot be started before fragment is in created state
at androidx.fragment.app.Fragment$8.launch(Fragment.java:3351)
at androidx.activity.result.ActivityResultLauncher.launch(ActivityResultLauncher.java:42)
at com.twofortyfouram.locale.sdk.host.edit.AbstractSupportPluginEditFragment.onCreate(AbstractSupportPluginEditFragment.java:173)
at androidx.fragment.app.Fragment.performCreate(Fragment.java:2867)
at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:444)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1287)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1444)
at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1522)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1575)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:455)
at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2299)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2084)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2022)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1924)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:489)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)