F00L.r
F00L.r

Reputation: 19

Android Multiwindow on Android 11 +

I want to launch third-party apps on floating window I tried :

try {ActivityOptions mOptions = ActivityOptions.makeBasic();
        Intent i = c.getPackageManager().getLaunchIntentForPackage(s)
                .addCategory(Intent.CATEGORY_LAUNCHER)
                .addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT |
                          Intent.FLAG_ACTIVITY_NEW_TASK |
                          Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
                Class<?> cls = Class.forName("android.app.ActivityOptions");
                cls.getMethod("setLaunchWindowingMode", new Class[]{Integer.TYPE}).invoke(mOptions, new Object[]{new Integer(5)});
            Rect mBounds = new Rect(300, 0, 500, 650);
            mOptions = mOptions.setLaunchBounds(mBounds);
            c.startActivity(i, mOptions.toBundle());
        } catch (Exception e) {Toast.makeText(c, "" + e, Toast.LENGTH_LONG).show();}

This code works on on Android 10 and below but not on Android 11 and up what is wrong?

I want to launch apps like this

Multi window on Android pie

Upvotes: 1

Views: 556

Answers (0)

Related Questions