I'm trying to get the screen rotation event. For that I'm using "OnConfigurationChanged".
The problem is my Activity definition which looks like
[Activity(ConfigurationChanges = global::Android.Content.PM.ConfigChanges.Orientation | global::Android.Content.PM.ConfigChanges.KeyboardHidden)]
I'm not able to provide the configuration global::Android.Content.PM.ConfigChanges.SreenSize which leads to the problem, that OnConfigurationChanged is not called.
My workaround is to add to the configuration to the AndroidManifest.xml which is kind of a hack.
<activity
android:name="mpa.gui.android.activities.HomeActivity"
android:configChanges="orientation|keyboardHidden|screenSize">
</activity>
I'm using
- Visual Studio 2012.
- My android project targets API level is 17
- Minimum Android target is set to Android 2.3
the AndroidManifest also configures this
Any idea why i can't configure the ScreemSize in my Activity?
Any help is appreciated.
You need to OR Android.Content.Pm.ConfigChanges.ScreenSize to trigger the onConfigurationChanged event for screen orientation changes in versions of Android higher than API level 13.
EG:
[Activity(Label = "MyActivity", ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation|Android.Content.PM.ConfigChanges.ScreenSize)]
Source:
https://stackoverflow.com/a/7366180/1099111
Related
Different configChanges for different android os version for single activity
<activity
android:name=".Activity_JoinMeeting"
android:configChanges="orientation|screenSize|layoutDirection|locale"
android:screenOrientation="landscape"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustPan|stateHidden"/>
configChanges for android OS 23 I want set set 4 properties and configChanges for android OS above 23 I want set 2 properties
how can I achive it
You can define two different activity in AndroidManifest file one for above android api 23 and other for rest android apis.
and launch that activies after checking api,
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP){
}
You can check the answer of aorlondo in this post and maybe try this solution with each properties you want to change.
I am trying to disable multi window feature of android. I have read the android documentation and know that resizeableActivity would only work for android N (API level 24) but I want to disable it on lower level android APIs. As Samsung devices have multi window feature on its all device (approx). So I have to disable it.
You cannot do that in runtime. Your application either supports multi window mode, or it doesn't. Parameters, that are given in AndroidManifest.xml cannot be changed during runtime.
From the documentation of android:resizeableActivity:
If this attribute is set to true, the activity can be launched in split-screen and freeform modes. If the attribute is set to false, the activity does not support multi-window mode. If this value is false, and the user attempts to launch the activity in multi-window mode, the activity takes over the full screen.
For specifically Samsung devices you can try putting this in manifest file:
<meta-data android:name="com.sec.android.support.multiwindow" android:value="false" />
<meta-data android:name="com.samsung.android.sdk.multiwindow.multiinstance.enable"
android:value="false" />
<meta-data android:name="com.samsung.android.sdk.multiwindow.penwindow.enable"
android:value="false" />
After many attempts I could only do so on the lollipop!!!
#Awais
Settings.System.putInt(this.context.getContentResolver(), multi_window_enabled", 0 );
When Android backgrounds an application it creates a screenshot of the current screen. The screenshot is displayed when you click the Overview button.
Is there a way to prevent this backgrounding screen shot (as if I'd used FLAG_SECURE), but allow the users to take screenshots?
You can configure not to show your activity in recent list. Add following code in manifest :
<activity
.....
android:excludeFromRecents="true"
...../>
Or from java code startActivity with flag:
intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
Or,
<activity
.....
android:noHistory="true"
...../>
Try this https://stackoverflow.com/a/49442984/5939067 .
The solution above simply sets the secure flag when your app goes background, and clears it when it resumes(so you can take the screenshot while using the app).
It works perfectly for me. I tested with Samsung Galaxy 9+(Android 9), LG V30(Android 8) and LG G7 ThinQ(Android 8).
I have an activity that I want not be seen in the Recents items. I have used the following in my Manifest file :
<activity
android:name=".WidgetLayout"
android:excludeFromRecents="true"
android:launchMode="singleInstance"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppTheme.Dialog">
It works perfectly well on all android versions but when I try it on Lollipop (SDK 21) it shows up always in the Recent items. So is it an OS bug as stated by many or I have made some error. Is there a solution to the problem if yes then how can I solve it ?
This is a known issue into Android 5.0, since L preview.
Try with android:taskAffinity
android:taskAffinity=".WidgetLayout"
android:excludeFromRecents="true"
You Should try adding android:autoRemoveFromRecents="true"
I am using facebook sdk in my app. In order not to show the solo progress bar when facebook button is clicked, I am using:
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="#android:style/Theme.NoDisplay"
</activity>
However, I think for devices with api 23+ this causes a crash:
"com.facebook.FacebookActivity did not call finish() prior to onResume() completing"
Someone said here:Activity did not call finish? (API 23) by writing:
#Override
protected void onStart() {
super.onStart();
setVisible(true);
}
in the problematic activity, they solved the issue. But since I cannot edit FacebookActivity, is there any alternative solution?
Facebook have changed their instructions for initially setting up your project. Just change the theme for the com.facebook.FacebookActivity to #android:style/Theme.Translucent.NoTitleBar.
See javadoc of windowNoDisplay :
(...)your activity must immediately quit without waiting for user interaction(...)
So exception is correct, your use case does not match windowNoDisplay.
This is platform bug.
If you have been using Theme.NoDisplay in one or more activities in
your app, and you have not tested them on Android 6.0 yet, I recommend
that you do so soon. An undocumented regression in Android 6.0 will
cause some of those activities to crash upon launch, if your
targetSdkVersion is 23 or higher.
See this blog post: https://commonsware.com/blog/2015/11/02/psa-android-6p0-theme.nodisplay-regression.html