platform-samples
platform-samples copied to clipboard
Add safer intents sample
/gemini summary
Summary of Changes
This pull request adds a new sample, SaferIntents, to demonstrate the importance of handling intents correctly to avoid potential crashes. The sample includes two buttons: one that sends a NULL intent (which is now handled with exception handling to prevent crashes) and another that sends a regular intent. The PR also updates the Gradle configuration, including upgrading the Android Gradle Plugin (AGP) and Gradle version, and adjusts the minimum SDK version for the app.
Highlights
- New Sample: SaferIntents: Introduces a new sample demonstrating how to handle intents safely to prevent
ActivityNotFoundExceptioncrashes when a NULL intent is sent. - Gradle Updates: Updates the Gradle version to 8.6 and the Android Gradle Plugin (AGP) to 8.4.1. Also, the minimum SDK version is increased to 24.
- Workflow Updates: Updates the GitHub Actions workflow to use
actions/checkout@v4andactions/upload-artifact@v4and targets API levels 31 and 34 for testing.
Changelog
Click here to see the changelog
- .github/workflows/build.yml
- Updates
actions/checkoutto v4 (line 19). - Updates
actions/upload-artifactto v4 (lines 49, 56, and 97). - Changes
runs-ontomacos-latest-large(line 63). - Updates the API levels tested to 31 and 34 (line 67).
- Updates
- app/build.gradle.kts
- Increases
minSdkto 24 (line 37).
- Increases
- gradle/libs.versions.toml
- Updates
agpto version 8.4.1 (line 21). - Updates Gradle version to 8.6 (line 20).
- Updates
- gradle/wrapper/gradle-wrapper.properties
- Updates
distributionUrlto Gradle 8.6 (line 20).
- Updates
- samples/README.md
- Adds a link to the new SaferIntents sample (line 93).
- samples/security/intents/README.md
- Creates a README file for the SaferIntents sample, explaining its purpose and functionality.
- samples/security/intents/build.gradle.kts
- Creates a build.gradle.kts file for the SaferIntents sample, including the plugin and namespace.
- samples/security/intents/src/main/AndroidManifest.xml
- Creates an AndroidManifest.xml file for the SaferIntents sample, declaring the SaferIntentsActivity and intent filter.
- samples/security/intents/src/main/java/com/example/platform/security/intents/SaferIntents.kt
- Creates the SaferIntents composable function, which includes buttons to send a NULL intent (with exception handling) and a regular intent.
- samples/security/intents/src/main/java/com/example/platform/security/intents/SaferIntentsActivity.kt
- Creates the SaferIntentsActivity, which displays a simple "Hello Android!" screen.
Activity
- yrezgui requested a summary of the pull request using the command
/gemini summary. - yrezgui suggested using
RequiresApiannotation instead of upgrading theminSdkversion. - yrezgui suggested inlining the
HelloAndroidScreenfunction directly inside theSurfacecomposable. - yrezgui asked for clarification on whether the activity can be launched with a NULL intent without the intent action filter, and if so, to explain it in the comments.