4

I have a problem with Samsung's 'Open in pop-up view' option. My app uses jfeinstein10/SlidingMenu lib (not updated in 4 years) and the problem described below affects only the activty that uses it.

SlidingMenu messes with android's DecorView and I know (from the stacktrace below) that Samsung's 'Open in pop-up view' uses DecorCaptionView which I suppose has something to do with the DecorView.

The problem is that every time a user on Samsung device (namely Galaxy S7) presses 'recents button' and moves the app to the 'Open in pop-up view' box as in the photo below:

Samsung S7 Open in pop-up view

the following exception is thrown:

Fatal Exception: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
   at android.view.ViewGroup.addViewInner(ViewGroup.java:4656)
   at android.view.ViewGroup.addView(ViewGroup.java:4497)
   at com.android.internal.widget.DecorCaptionView.addView(DecorCaptionView.java:358)
   at android.view.ViewGroup.addView(ViewGroup.java:4469)
   at com.android.internal.policy.DecorView.onConfigurationChanged(DecorView.java:2053)
   at com.android.internal.policy.PhoneWindow.onMultiWindowModeChanged(PhoneWindow.java:747)
   at android.app.Activity.dispatchMultiWindowModeChanged(Activity.java:7177)
   at android.app.ActivityThread.handleMultiWindowModeChanged(ActivityThread.java:3212)
   at android.app.ActivityThread.-wrap16(ActivityThread.java)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1866)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:154)
   at android.app.ActivityThread.main(ActivityThread.java:6692)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

and my app crashes.

After some code investigation I found out that this block of SlidingMenu lib code causes the problem:

    case SLIDING_WINDOW:
        mActionbarOverlay = false;
        ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
        ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
        // save ActionBar themes that have transparent assets
        decorChild.setBackgroundResource(background);
        decor.removeView(decorChild);
        decor.addView(this);
        setContent(decorChild);
        break;

but I cannot debug it when while this opening in pop-up happens.

Does anybody have any suggestions how to fix this ?

I have already tried switching off Samsung's multiwindow options explicitly in the AndroidManifest:

    <meta-data
        android:name="com.samsung.android.sdk.multiwindow.enable"
        android:value="false" />
    <meta-data
        android:name="com.samsung.android.sdk.multiwindow.multiinstance.enable"
        android:value="false" />
    <meta-data
        android:name="com.sec.android.multiwindow.STYLE"
        android:value="fixedRatio" />
    <meta-data
        android:name="com.sec.android.support.multiwindow"
        android:value="false" />

but with no success.

Jerzy Kiler
  • 2,795
  • 4
  • 18
  • 12

1 Answers1

0

You can try these two solutions:

  1. after decor.addView(this);, add this block:

try {
  Field field = decor.getClass().getDeclaredField("mContentRoot");
  field.setAccessible(true);
  field.set(decor, this);
} catch (Exception e) {
  // do something
}
  1. add android:resizeableActivity="false" to 'application' element in AndroidManifest.xml, to disable multiwindow.
eisbehr
  • 12,243
  • 7
  • 38
  • 63
Wind
  • 1
  • 1