Adding Samsung multi-window support to Android application
Asked Answered
R

4

27

I went and tried to add Samsung's multi-window support for my app following this link. My app did appear in Samsung's multi-window applications tab, and I was able to drag and drop it into the screen, however my app did not behave as multi-window supported app should behave, but instead expanded to full screen.

I think there are some other changes that are need to be made to get it work properly, but I have no idea what. Does anyone have any ideas what could be the problem causing this behaviour?

Redeem answered 1/1, 2013 at 13:54 Comment(0)
K
69

This xda-developers forum post contains a step-by-step guide, which I've paraphrased here.

Make sure your manifest contains the following somewhere inside the <application> tag:

<uses-library android:required="false" android:name="com.sec.android.app.multiwindow" />
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true" />
<meta-data android:name="com.sec.android.multiwindow.DEFAULT_SIZE_W" android:resource="@dimen/app_defaultsize_w" />
<meta-data android:name="com.sec.android.multiwindow.DEFAULT_SIZE_H" android:resource="@dimen/app_defaultsize_h" />
<meta-data android:name="com.sec.android.multiwindow.MINIMUM_SIZE_W" android:resource="@dimen/app_minimumsize_w" />
<meta-data android:name="com.sec.android.multiwindow.MINIMUM_SIZE_H" android:resource="@dimen/app_minimumsize_h" />

For the desired activity, add to its <intent-filter> tag:

<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />

Be sure to define the dimensions above in a resource file.

In the comments section of that blog post a user mentions that the minimum size was causing a problem for him and suggested removing com.sec.android.multiwindow.MINIMUM_SIZE_W and com.sec.android.multiwindow.MINIMUM_SIZE_H.

One user pointed out that specifying the dimensions through a dimension resource didn't work for him; he instead hardcoded the value attribute:

<uses-library android:required="false" android:name="com.sec.android.app.multiwindow" />
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true" />
<meta-data android:name="com.sec.android.multiwindow.DEFAULT_SIZE_W" android:value="632.0dip" />
<meta-data android:name="com.sec.android.multiwindow.DEFAULT_SIZE_H" android:value="598.0dip" />
<meta-data android:name="com.sec.android.multiwindow.MINIMUM_SIZE_W" android:value="632.0dip" />
<meta-data android:name="com.sec.android.multiwindow.MINIMUM_SIZE_H" android:value="598.0dip" />

I'm afraid I can't try myself as I don't have a Galaxy Note.

Kenspeckle answered 6/1, 2013 at 18:39 Comment(16)
I had done that already, otherwise it gave me error and I couldnt even compile it. But my problem is just that my program takes the whole screen and doesnt let the other multi screen capable programs to share the screen.Redeem
The last comment on the page suggests: "Also it seems that if the DEFAULT/MINIMUM settings are left out, the default is to make the app fill half the screen when dragged in, and have a minimum size that corresponds to the height of the actionbar."Kenspeckle
Which device is it? Is it running Android 4.1?Kenspeckle
Odd; it should work. Are you sure you have included <uses-library required="false" name="com.sec.android.app.multiwindow" /> and all your <meta-data> tags are immediately inside <application>? I updated my answer to illustrate this.Kenspeckle
I was missing this line <meta-data android:name="com.sec.android.support.multiwindow" android:value="true" />. Thanks for help :)Redeem
Glad it worked! For the record, I also stumbled upon this blog post suggesting that Multi Window doesn't work in conjunction with screenOrientation.Kenspeckle
Im having similar problem. the code work on galaxy s3 with 4.1.2 but not working in galaxy note 2 with 4.1.1. Any ideas?Dwarf
If its not working for you ... reduce dimi ... it worked for me with 300dip ... and s3 ..Dode
As i am also researching on this topic, i found an official Samsung guide about their Multi Window feature, that i guess it would help: developer.samsung.com/s-pen-sdk/technical-docs/…Ensconce
Worked fine for me on 1st try. For simplicity, I omit dimens.xml and changed android:resource="@dimen/app_defaultsize_w" to android:value="632dp", etc. And note, you can test yourself on developer.samsung.com/remotetestlab even if you don't have Samsung device.Dehypnotize
Won't these tags cause any crash on non-Samsung devices? Tested on my old Samsung galaxy S which doesn't support multi-window feature and didn't have any problem but I wonder if it's the same on other devices..Bibliomancy
@Jenix: No; the library isn't required and you may always add meta data in the manifest.Kenspeckle
Thanks a million!!Bibliomancy
Great. But how do I know when screen size is changed? Regular onConfigurationChanged() callback does not work when user resizes the window.Liber
Is there a way to enable this in only one activity?Fleshings
Is this still relevant in 2023?Erg
M
3

After testing my application on Galaxy Note 3 I found out two more things:

MINIMUM_SIZE and DEFAULT_SIZE only works on MultiWindow for Samsung tablets, not in smartphones.

Also if you want to enable Multi-Instance in your application add this line to your AndroidManifest:

<meta-data
            android:name="com.samsung.android.sdk.multiwindow.multiinstance.enable"
            android:value="true" />
Mcsweeney answered 29/10, 2013 at 1:19 Comment(0)
G
0

Also worth noting is enabling Pen Window (part of the multi-window system) for your app, along side Multi-Window and Multi-Instance as noted here (http://forum.xda-developers.com/showthread.php?t=2499720):

<meta-data android:name="com.samsung.android.sdk.multiwindow.penwindow.enable" android:value="true" />

and add the Launcher code to your activity:

<category android:name="android.intent.category.PENWINDOW_LAUNCHER" />

As a note to the launcher code, the xda post has it listed with a com.samsung prefix, but I couldn't get it to work on my N3 as described there (I used the modified code above). In the Pen Window, you'll have to hit edit and drag your app from the bottom into the Pen Window Launcher screen before you can use it.

Glyceride answered 14/10, 2014 at 6:22 Comment(0)
U
0

To support multi window on Android 7 and higher, just set this android:resizeableActivity to true in your manifest's 'activity' or 'application' element :

android:resizeableActivity="true"

https://developer.android.com/guide/topics/ui/multi-window.html

Unarm answered 10/5, 2017 at 13:23 Comment(1)
Be aware, this is the split-screen multi-window offered by Android, not the specialized multi-window available to Note devices. It does not provide the same functionality.Nisa

© 2022 - 2024 — McMap. All rights reserved.