Created
June 22, 2022 14:43
-
-
Save s3va/f3339017d64898dd53441260efc9ec20 to your computer and use it in GitHub Desktop.
Checking if my service is running.
This file contains 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
private fun isMyServiceRunning(serv: String): Boolean { | |
val manager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager | |
return manager.getRunningServices(Integer.MAX_VALUE) | |
.any { | |
Log.e(TAG, "isMyServiceRunning: ${it.service.shortClassName}") | |
it.service.shortClassName == serv | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment