Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Here is Kotlin code for Android installation #283

Open
mi5ha opened this issue Dec 14, 2023 · 4 comments
Open

Here is Kotlin code for Android installation #283

mi5ha opened this issue Dec 14, 2023 · 4 comments

Comments

@mi5ha
Copy link

mi5ha commented Dec 14, 2023

@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())
}
@mi5ha mi5ha changed the title Here is Kotlin code for installation Here is Kotlin code for Android installation Dec 14, 2023
@NikhilMasurkar
Copy link

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

@mi5ha
Copy link
Author

mi5ha commented Dec 14, 2023

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

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

@AntonioArts
Copy link

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?

@mi5ha
Copy link
Author

mi5ha commented Jan 31, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants