OnConfigurationChanged not called in mono android

I am trying to get a screen rotation event. For this I use "OnConfigurationChanged".

The problem is determining my activity, which looks like

[Activity(ConfigurationChanges = global::Android.Content.PM.ConfigChanges.Orientation | global::Android.Content.PM.ConfigChanges.KeyboardHidden)] 

I cannot provide the configuration global :: Android.Content.PM.ConfigChanges.SreenSize, which leads to the problem that OnConfigurationChanged is not being called.

My workaround is to add AndroidManifest.xml to the configuration, which is a kind of hack.

 <activity android:name="mpa.gui.android.activities.HomeActivity" android:configChanges="orientation|keyboardHidden|screenSize"> </activity> 

I am using - Visual Studio 2012.
- My Android project project level is 17%
- The minimum target audience of Android is installed on Android 2.3

AndroidManifest also configures this

Any idea why I can't configure ScreemSize in my work?

Any help is appreciated.

+4
source share
1 answer

You need OR Android.Content.Pm.ConfigChanges.ScreenSize raise the onConfigurationChanged event to change the screen orientation in Android versions above API level 13.

EG:

 [Activity(Label = "MyActivity", ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation|Android.Content.PM.ConfigChanges.ScreenSize)] 

Source: fooobar.com/questions/146413 / ...

+2
source

Source: https://habr.com/ru/post/1493697/


All Articles