WaxMoon / MultiApp

A customizable virtual Android container/一款可定制的虚拟安卓容器
GNU Affero General Public License v3.0
799 stars 166 forks source link

ActivityOptions setLaunchDisplayId not working #29

Closed trickymagus closed 1 year ago

trickymagus commented 1 year ago
    public static int startActivity(Intent intent, int userId) {
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
            intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK);
            ActivityOptions options = ActivityOptions.makeBasic().setLaunchDisplayId(65);

            return (int) Cmd.INSTANCE().exec(
                    CmdConstants.CMD_START_ACTIVITY,
                    intent,
                    options.toBundle(),
                    userId
            );
        } else {
            return (int) Cmd.INSTANCE().exec(
                    CmdConstants.CMD_START_ACTIVITY,
                    intent,
                    null,
                    userId
            );
        }
    }

I changed startActivity in opensdk/HackApi.java to test setLaunchDisplayId working. But application always starts in main display, not secondary display. In the developer options, you can enable the 'simulate secondary display' option and obtain the displayId to test this code.

WaxMoon commented 1 year ago

plz test latest opensdk