The extension functions for android.os.Environment that is currently provided by KEnvironment.kt cannot be used without first creating an instance of Environment which isn't desirable because android.os.Environment is just meant as a utility class filled with static methods.
To access the provided extension functions I have to write this:
if (Environment().isExternalStorageWritable()) {
…
}
That is, notice Environment() and not Environment which means I have to create an instance of Environment first before using it.
Therefore the extension functions provided by KEnvironment.kt is not usable or practical. I would say either removing it or changing them into top-level functions instead.
The extension functions for
android.os.Environment
that is currently provided by KEnvironment.kt cannot be used without first creating an instance ofEnvironment
which isn't desirable becauseandroid.os.Environment
is just meant as a utility class filled with static methods.To access the provided extension functions I have to write this:
That is, notice
Environment()
and notEnvironment
which means I have to create an instance ofEnvironment
first before using it.It is currently not possible in Kotlin to provide static extension functions to existing java classes. See, https://discuss.kotlinlang.org/t/static-extension-methods-for-java-classes/2190
Therefore the extension functions provided by KEnvironment.kt is not usable or practical. I would say either removing it or changing them into top-level functions instead.