I’m working on an application that required the screen orientation is landscape locked. But whenever the system notification is showing, I still be able to rotate the screen orientation to portrait. For example, the notification about “Allow app to find, connet to nearby device” or “Do you want to update this app”.
notification example
I already used these code to lock the app orientation in Flutter:
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
And add these code in tag of AndroidManifest.xml file:
android:screenOrientation="landscape"
And try these code on MainActivity.java file:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
}
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
GeneratedPluginRegistrant.registerWith(flutterEngine)
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
}
How can I lock the screen orientation even when a system notification is showing?
Thank for making a read!!
Bách is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.