Class Clazz in Kotlin
How Does Class Clazz Look Like in Kotlin? I'm Trying to Translate This Method to Kotlin Code and It Seems Like I'm Stuck. Public Static Boolean...
How does Class<?> clazz look like in Kotlin ?
I'm trying to translate this method to Kotlin code and it seems like I'm stuck.
public static boolean isServiceRunning(Context context, Class<?> serviceClass)
2 Answers
fun isServiceRunning(context: Context, serviceClass : Class<Any>) : Boolean
something like that should do the job
You can define it as
companion object {
fun isServiceRunning(context: Context, serviceClass: Class<*>): Boolean { /* ... */ }
}
The Class<*> star-projection is almost equivalent to the Java unbounded wildcard Class<?>.