fix(android): remove unchecked Java compilation warnings

AJ
5d ago
+3-3

Closes #8529

Description

Adds the missing generic type arguments so javac no longer reports unchecked warnings in the Android library:

  • Plugin.notifyListeners: new CopyOnWriteArrayList<>(listeners) instead of the raw CopyOnWriteArrayList
  • BridgeWebChromeClient: ActivityResultLauncher<String[]> for permissionLauncher and ActivityResultLauncher<Intent> for activityLauncher, matching the RequestMultiplePermissions and StartActivityForResult contracts they are registered with

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation
  • Other (CI, chores, etc.)

Rationale / Problems Fixed

The raw types cause 8 [unchecked] warnings when the library is compiled with -Xlint:unchecked (#8529). All existing call sites already pass String[] and Intent, so this is a compile-time-only change with no runtime behaviour change and no API change: both fields are private.

Note: the line numbers in the issue are off by one for the last three activityLauncher.launch(...) call sites on current main (351, 370, 402).

Tests or Reproductions

Compiled capacitor-android with JDK 21 and -Xlint:unchecked enabled via a Gradle init script:

allprojects {
    tasks.withType(JavaCompile).configureEach {
        options.compilerArgs << "-Xlint:unchecked"
    }
}
cd android
./gradlew -b capacitor/build.gradle --init-script xlint.gradle compileReleaseJavaWithJavac --rerun-tasks
  • Before: 8 warnings — Plugin.java:683 (×2), BridgeWebChromeClient.java:120, 267, 298, 351, 370, 402
  • After: 0 warnings
  • npm run verify (in android/) passes

Screenshots / Media

N/A

Platforms Affected

  • Android
  • iOS
  • Web

Notes / Comments

  • No behaviour change, safe to include in an 8.x patch release.
  • Patch prepared with AI assistance; reviewed and tested locally by me