Something wrong with this code

Hello,
I was making an extension
Java code :

import android.app.Activity;
import android.os.Build;
import android.view.WindowManager;

@SimpleFunction(description = "")
public void ShowInCutout() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        activity.getWindow().getAttributes().layoutInDisplayCutoutMode =
                WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
    }
}

But when i was making the test, the first click didn’t trigger the code meaning it didn’t work but the second try was working. So i needed to make it once, how can i trigger it once only, not twice?

To test the apk test by yourself :

  1. Open the app
  2. Landscape your phone
  3. Start click on the button until something changed, thats it
  4. If you saw my problem, please just fix it

Thank you.

@JEWEL can you help here.

I think i found the solution

=

activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

WindowManager.LayoutParams params = activity.getWindow().getAttributes();
params.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;

activity.getWindow().setAttributes(params);

It looks like he already solved it and published the extension here :arrow_down:

Yeah, that extension was the extension that i made it!

1 Like

@User_Enforce that means the problem is solved, i am closing this topic.

2 Likes