chore(demo): add DemoApplication for API key/Map ID validation#1600
Merged
chore(demo): add DemoApplication for API key/Map ID validation#1600
Conversation
Introduces a centralized mechanism to validate the Maps API key and configure a Map ID, which is required for features like Advanced Markers. This change adds a new `DemoApplication` class that runs two checks on startup: - `checkApiKey()`: Validates that a non-default API key is present in the manifest metadata. - `getMapId()`: Retrieves a Map ID, prioritizing `secrets.properties` (via `BuildConfig`) and falling back to `strings.xml`. `BaseDemoActivity` is refactored to: - Get the Map ID from `DemoApplication`. - Programmatically create the `SupportMapFragment` using `GoogleMapOptions` to apply the `mapId`. This replaces the previous method of inflating the map from an XML layout, which didn't allow for easy programmatic Map ID configuration. Documentation in `README.md` is updated to reflect the new configuration options for setting the Map ID.
Contributor
Code Coverage
|
Allows the demo application to run even when a map ID is not provided by instantiating the `SupportMapFragment` without `GoogleMapOptions`.
kikoso
reviewed
Sep 16, 2025
Contributor
|
🎉 This PR is included in version 3.19.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
chore(demo): add DemoApplication for API key/Map ID validation
Introduces a centralized mechanism to validate the Maps API key and configure a Map ID, which is required for features like Advanced Markers.
This change adds a new
DemoApplicationclass that runs two checks on startup:checkApiKey(): Validates that a non-default API key is present in the manifest metadata.getMapId(): Retrieves a Map ID, prioritizingsecrets.properties(viaBuildConfig) and falling back tostrings.xml.BaseDemoActivityis refactored to:DemoApplication.SupportMapFragmentusingGoogleMapOptionsto apply themapId.This replaces the previous method of inflating the map from an XML layout, which didn't allow for easy programmatic Map ID configuration.
Documentation in
README.mdis updated to reflect the new configuration options for setting the Map ID.