Disable multi window feature programmatically - android

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 );

Related

How can I disable multiwindow mode for app Android

By setting this android:resizeableActivity="false" flag just gives a message that "App may not work in split mode" . But the app still goes to the split screen mode. I used this tag like this
<application android:resizeableActivity="false" > ... </application>
MinSDKVersion - 24
I have tried many solution but didn't find any luck.
https://stackoverflow.com/a/46603618/10279394
Disable multi window feature programmatically
How can i disable it ?

Hide the screenshot from the Overview/Recent screen

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).

Disabling Multi-window feature for Android N not working for an activity

I want to disable multi-window support for an activity in my app.
I have set resizeableActivity to false in my Manifest but when I long press recent app icon, the app still goes in multi-window mode. Below is my manifest:
<activity
android:name=".MainActivity"
android:resizeableActivity="false"
android:excludeFromRecents="true"
android:icon="#drawable/ic_launcher_home"
android:theme="#style/AppThemeV3.CustomToolbar">
</activity>
Per documentation:
android:resizeableActivity=["true" | "false"]
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.
I have also tried to set this attribute to false at application level in manifest but it still starts in multi-window mode. Any pointer on what I am doing wrong will be highly appreciated?
The activity that is at the root of the task controls the window size. Your choices are:
Trace back to all possible task root activities in your app and ensure they all also have android:resizeableActivity="false"
Force this activity into another task, via Intent flags when you start it or manifest settings
[UPDATE] set android:resizeableActivity="false" in application tag. This will work now.
I have meet this problem before, and I try many time find that your must
add android:launchMode="singleTask" && android:resizeableActivity="false"
at the same time.

Android Custom Launcher doesn't stop the BootAnimation

I am working on a custom launcher for Android, in a project using BBBAndroid (android v4.4.4 w/ kernel 3.8 for the beagleboneblack):
http://bbbandroid.sourceforge.net
I created aosp_stripped.mk to strip some unneeded Android packages and replace the Launcher2 and the HOME packages with my CustomLauncher. This launcher is mostly an normal app with the LAUNCHER and HOME category added in its AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test.customlauncher" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_people"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library
android:name="test.service.lib"
android:required="true" />
<activity
android:launchMode="singleTask"
android:stateNotNeeded="true"
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
It effectively replaces Launcher2, but the boot animation doesn't stop until 40 seconds later, logcat shows:
W/WindowManager( 591): ***** BOOT TIMEOUT: forcing display enabled
I/PowerManagerService( 591): Boot animation finished.
So my launcher must be missing something to tell the boot animation to stop. I found some hints here: http://forum.xda-developers.com/showthread.php?t=2485118
Indeed, I have some missing Wallpaper classes errors in logcat, but I didn't remove the SystemUI package. I noticed that when using Launcher2/Home, this error only happens on the first boot. Using my custom launcher, it happens on every boot. Besides this error, I didn't find any differences:
W/WallpaperService( 591): Attempted wallpaper ComponentInfo{com.android.wallpaper/com.android.wallpaper.fall.FallWallpaper} is unavailable
W/WallpaperService( 591): Failure starting previous wallpaper
W/WallpaperService( 591): Attempted wallpaper ComponentInfo{com.android.wallpaper/com.android.wallpaper.fall.FallWallpaper} is unavailable
E/WallpaperService( 591): Default wallpaper component not found!
I found this class in the package LiveWallpapers in packages/wallpapers/Basic (AOSP). It is already added in PRODUCT_PACKAGES, but this package is nowhere in out/target/product/beagleboneblack/ :(
Right now I am digging in Launcher2 and WallPaperManager to see what could trigger the BootAnimation to stop...
Thanks in advance !
Update
I also tried to stop the bootanimation using system properties, but the touchscreen is not usable until the BOOT_TIMEOUT event:
import android.os.SystemProperties;
// inside a Service with system privileges
SystemProperties.set("service.bootanim.exit", "1");
Tracing the BOOT TIMEOUT problem, it comes from WindowManagerService performEnableScreen() waiting for a wallpaper to be set/active, the boot isn't considered done otherwise:
// If we are turning on the screen after the boot is completed
// normally, don't do so until we have the application and
// wallpaper.
if (mSystemBooted && ((!haveApp && !haveKeyguard) ||
(wallpaperEnabled && !haveWallpaper))) {
return;
}
I also noticed that the wallpapers apks in packages/wallpapers are not built for the target because the bbbandroid repo lacks opengl support for now.
My current workaround for this problem is to disable the WallpaperService via its internal config.xml file:
diff --git a/frameworks/base/core/res/res/values/config.xml b/frameworks/base/core/res/res/values/config.xml
index 6efb4a4..0c873b7 100644
--- a/frameworks/base/core/res/res/values/config.xml
+++ b/frameworks/base/core/res/res/values/config.xml
## -701,7 +701,7 ##
<string name="default_wallpaper_component" translatable="false">#null</string>
<!-- True if WallpaperService is enabled -->
- <bool name="config_enableWallpaperService">true</bool>
+ <bool name="config_enableWallpaperService">false</bool>
<!-- Whether to enable network location overlay which allows network
location provider to be replaced by an app at run-time. When disabled,
This solution works if you don't mind using modified android sources.
I think that the problem is not with your launcher app, in this case you would see in logcat errors from your app. Usually boot animation hangs when SystemUI can't start (due to a failure).
Launcher app itself doesn't stop boot animation, it doesn't have this functionality.
You probably disabled some critical component which breaks boot workflow. Yes, wallpapers can affect it. I would recommend to put everything back in your .mk file, check that it builds and boots OK, then replace launcher only with your app. Then you can cut mk file further to check which module creates the issue.
I do not remember exactly but Browser module may include webview component which is used by many components.
You should post full logcat output, and may be dmesg output as well.

OnConfigurationChanged not called in mono android

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

Categories

Resources