1

I'm trying to develop an Android application with Kotlin, but a third party sdk that I am working with requires "GlobalApplication.getGlobalApplicationContext()" which doesn't seem to exist on the Kotlin version.

I converted instruction written in Java code to Kotlin code, but I couldn't find how to convert a line, which is - GlobalApplication.getGlobalApplicationContext()

@Override
public Context getApplicationContext() {
    return GlobalApplication.getGlobalApplicationContext(); // This line
}

getApplicationContext seems to return a context object containing some data about the application, but I couldn't find a Kotlin version of it. Any help will be very appreciated, Thanks!

Minjae Park
  • 253
  • 1
  • 3
  • 12

1 Answers1

1

Just return your application context.

For Java :

@Override
public Context getApplicationContext() {
    return getApplicationContext();
}

For Kotlin :

override fun getApplicationContext() : Context {
    return applicationContext
}
Ashish
  • 6,791
  • 3
  • 26
  • 48