Search code examples
javaandroidkotlinandroid-configchanges

Trigger configuration changes manually in java Android


I have a scenario in my app where the expected behavior occurs during a device configuration change, such as an orientation change. This means that whenever the user changes the device's orientation, the app's configuration reloads.

Now, I would like to trigger this behavior manually in Java. How can I achieve this in a click listener?


Solution

  • You can call recreate() or change the orientation programmatically using setRequestedOrientation().