kcxt
is a kotlin context-awareness android library. It is a helper for android library composer especially. Composers could get Application
, ApplicationContext
, Context
, and top of Activity
, at anywhere, at any time. Forget .setContext(context)
, or .withContext(MainActivity.this)
.
To use it, just import it from kcxt at JitPack.io, and get android Application
object by appGlobal
, or get the current android Activity
object by currentActivity
:
import com.obsez.android.libs.kcxt.appGlobal
import com.obsez.android.libs.kcxt.currentActivity
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
println(appGlobal?.dataDir)
}
println(appGlobal?.cacheDir)
println(currentActivity?.startActivity(intent))
kcxt
need AndroidX andActivityLifecycle
supports.
To import kcxt
in your library (or application):
dependencies {
// implementation "com.github.hedzr:kcxt:v1.3.12"
implementation "com.github.hedzr:kcxt:$kcxt_version"
}
See the badge above for the newest kcxt_version
.
Standard Apache 2.0.