SIGN IN SIGN UP

[GH] Add key support to ComponentActivity viewModels

Add key support to `ComponentActivity.viewModels`.

This adds a required `key: String` overload so callers can retain multiple `ViewModel` instances of the same type in a `ComponentActivity`'s `ViewModelStore`. Existing delegate signatures remain unchanged, while the new overload preserves the default `CreationExtras` and factory behavior and documents keyed usage.

The instrumentation coverage verifies that the same key returns the same instance, different and default keys return distinct instances, and keyed `SavedStateHandle` creation continues to receive the activity's default extras.

Test: `./gradlew :activity:activity:connectedReleaseAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=androidx.activity.ActivityViewModelLazyTest`
Test: `./gradlew :activity:activity:lintRelease :activity:activity:testReleaseUnitTest :activity:activity:ktCheck`
Test: `./gradlew :activity:activity:checkApi`
Fixes: b/133130644

This is an imported pull request from https://github.com/androidx/androidx/pull/900.

Resolves #900
Github-Pr-Head-Sha: 182d6753a77cc6dc22c56444f8369d99301c8191
GitOrigin-RevId: 5893fc92e9b56b0504a9b0450713dbd1cc02fb0a
Change-Id: Ib312dec27712578f32bc531fb9c3a303b12a3a7c
A
Arda K. committed
ca7c6610b304c64842ddb93fa01b3d1cecf60e8f
Parent: d1b4fc7
Committed by Copybara-Service <copybara-worker@google.com> on 8/26/2026, 3:35:59 AM