Is `This argument is a new instance so stopService will not remove anything` valid for `stopService(Intent(...))`, or is it a false positive?

3 hours ago 1
ARTICLE AD BOX

When I run Inspect Code in a specific version of Android Studio, I get a warning for the following code in MainActivity, specifically at the point where the Intent is created:

stopService( Intent( this, LocationService::class.java, ) )

Warning message:

Android Lint: Correctness group 1 warning Implicit SAM Instances inspection 1 warning file MainActivity.kt 1 warning WARNING This argument is a new instance so stopService will not remove anything

My main question is whether this warning is actually valid for this stopService(Intent(...)) call.

If the warning is correct, then I should fix the code regardless of version differences. If it is not correct, then I would like to understand why it is reported only in a specific environment.

The warning occurs in the following environment:

Android Studio Meerkat Feature Drop | 2024.3.2

AGP 8.10.1

compileSdk = 36

targetSdk = 36

ScreenShot

I have also confirmed that this warning does not occur in the following environments:

(I)

Android Studio Narwhal | 2025.1.1

AGP 8.10.1

compileSdk = 36

targetSdk = 36

(II)

Android Studio Meerkat Feature Drop | 2024.3.2

AGP 8.6.1

compileSdk = 35

targetSdk = 35

(III)

Android Studio Koala Feature Drop | 2024.1.2 Patch 1

AGP 8.6.1

compileSdk = 35

targetSdk = 35

Is this warning valid for this code, or is it likely a false positive in that specific environment?

Read Entire Article