wonday/react-native-orientation-locker

Here is Kotlin code for Android installation

mi5ha opened this issue · 4 comments

mi5ha commented

@wonday Here is Kotlin code needed for Android installation:

// MainActivity.kt

import android.content.Intent;
import android.content.res.Configuration;

override fun onConfigurationChanged(newConfig: Configuration) {
    super.onConfigurationChanged(newConfig)
    val intent = Intent("onConfigurationChanged")
    intent.putExtra("newConfig", newConfig)
    sendBroadcast(intent)
}
// MainApplication.kt

import org.wonday.orientation.OrientationActivityLifecycle

override fun onCreate() {
    ...

    // ADD AT THE END OF THE FUNCTION
    registerActivityLifecycleCallbacks(OrientationActivityLifecycle.getInstance())
}

@wonday I'm also still waiting for Kotlin changes.

mi5ha commented

@wonday I'm also still waiting for Kotlin changes.

Extension works OK with Kotlin, I gave this code for Readme file

Hey @mi5ha

override fun onCreate() {
    ...
    registerActivityLifecycleCallbacks(OrientationActivityLifecycle.getInstance())
}

Shouldn't it be added to the excisting method at the end of the onCreate where a lot of initialization is happening?

Yes thats what I wrote, I will just add that it should go at the end of onCreate