Show self in freeform window

166 Views Asked by At

I want to add a button in my App and touch it to show self in freeform window. what should I do? Can it be done?

my code is:

`public static void startFreeWindow() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            Activity activity = Cocos2dxHelper.getActivity();
            Intent intent = new Intent(activity, activity.getClass());
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT );
            ActivityOptions activityOptions = ActivityOptions.makeBasic();
            try {
                Method method = ActivityOptions.class.getMethod("setLaunchWindowingMode", int.class);
                method.invoke(activityOptions, 5);
            }catch (Exception e){
                Log.i("FreeForm", "getActivityOptions error = " + e);
            }
            activityOptions.setLaunchBounds(new Rect(0, 0, 500, 500));
            Bundle bundle = activityOptions.toBundle();
            activity.startActivity(intent, bundle);
        }
    }`

But Nothing happened. I made sure its executed the code(startActivity).

0

There are 0 best solutions below