I need to get a Context from my activity. When i do that using:
override fun getContext(): Context {
return activity.applicationContext
}
i got:
safe ( .) or non-null asserted ( .) calls are allowed on a nullable receiver of type FragmentACtivity
activity
is calling your fragment'sgetActivity()
which isn't guaranteed to not be null. So you'll have to doactivity!!.applicationContext!!
– ElliotMALT+ENTER
to get a solution to fix your problem - more often than not, it's Kotlin telling you to be hyper-conscious about nullability – ElliotM