findContextOfType

fun <T> findContextOfType(context: Context?, clazz: Class<out T>): T?

Returns the nearest context in the chain (as defined by ContextWrapper.getBaseContext()) which is an instance of the specified type, or null if one could not be found

Return

the first context which is an instance of the specified class, or null if none exists

Parameters

context

Initial context

clazz

Class instance to look for