Search code examples
androidandroid-windowmanagerpresentationmultiscreen

Launch another application in secondary screen in Android_O


Device have two screens.In the first screen normal UI(launcher app),and in the second screen to launch google maps app.

How can we launch another application secondary screen.

Service class:
@Override
protected View buildPresoView(Context ctxt, LayoutInflater inflater) {
View topView = new View(this);
  topView.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View arg0) {
          Intent i = getPackageManager().getLaunchIntentForPackage("abc.abc.abc");
  startActivity(i);
      }
  });

    inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View contentView = inflater.inflate(R.layout.display, null,false);    

    return(topView);
   //return(contentView);
  }
 PresentationHelper:
 @Override
public void showPreso(Display display) {
Context presoContext=createPresoContext(display);
LayoutInflater inflater=LayoutInflater.from(presoContext);
wm=(WindowManager)presoContext.getSystemService(Context.WINDOW_SERVICE);
presoView=buildPresoView(presoContext, inflater);
wm.addView(presoView, buildLayoutParams());
}

I have followed this link: Run a separate application on secondary monitor


Solution

  • First check presentation mode is enable or not in devices level (IN aosp). If not add the following tag in device .xml file.

    <feature name="android.software.activities_on_secondary_displays" />