Music-Player-GO
Music-Player-GO copied to clipboard
[Bug]:
What happened?
We confirm a compatibility issue which might threaten the robustness of your app and give a detailed suggestion for you.
In ''PlayerTileService", you invoke the framework API "<android.service.quicksettings.TileService: void startActivityAndCollapse(android.content.Intent)>" in "onClick" method as shown in following. But actually, this method is added in API level 24 (https://developer.android.google.cn/reference/android/service/quicksettings/TileService?hl=en#startActivityAndCollapse(android.content.Intent)).
class PlayerTileService : TileService() {
override fun onClick() {
super.onClick()
with(Intent(this, MainActivity::class.java)) {
putExtra(GoConstants.LAUNCHED_BY_TILE, GoConstants.LAUNCHED_BY_TILE)
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP
startActivityAndCollapse(this)
}
}
}}
So when the app try to initial related funtion on devices level 21 ~ 23, your app will run with an unpredictable results. So we suggest you add an "if(SDK_INT>23)" or change your app miniSDK from 21 to 24 to fix this potential issue.
Version
4.4.20
Device and Android version
API 21~23
Relevant log output
No response
More info
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
RequiresApi + intent filter (android.service.quicksettings.action.QS_TILE) should already do the trick
"Denotes that the annotated element should only be called on the given API level or higher"
You can't add tiles on 21~23 API π
Also, can't see any report of unpredictable in Google play dev console since the introduction of this feat.
But, yeah, gonna add that check if it helps to improve my app. Thanks
Actually, this annotation only suppresses the compiler's warning (i.e., Lint). It will be deleted in the apk package. And when this API is called before API 24, the app will still meet a crash. So we suggest add a SDK version check before invoke the API. (https://stackoverflow.com/questions/40007365/requiresapi-vs-targetapi-android-annotations)
TileService was added in API 24
https://developer.android.com/reference/android/service/quicksettings/TileService
I can't really understand how older devices can experience a crash if no tile is available.
@OxygenCobalt what's your take on this issue?
It won't run below API 24, as previous devices will not parse it from the manifest. I would recommend just adding @RequiresApi(24)
to the whole TileService
class to let other code know about it's nature.