title: ActivityView and launching activities on secondary display
body: <p>I'm trying to display (as a system-level application) multiple activities. There's an hidden AOSP class called <a href="https://android.googlesource.com/platform/frameworks/base.git/+/master/core/java/android/app/ActivityView.java" rel="nofollow noreferrer"><code>ActivityView</code></a> meant to do just that. Here's how you would use it, as far as I understand:</p>
  
  <pre><code>findViewById(R.id.view1).setCallback(object: ActivityView.StateCallback() {
      override fun onActivityViewReady(view: ActivityView?) {
          view?.startActivity(InnerActivity.getIntent(view.context, "my extra"))
      }
  
      override fun onActivityViewDestroyed(view: ActivityView?) {
          // Cleanup
      }
  })
  </code></pre>
  
  <p>Note that the inner activity has to be declared with the attribute <code>allowEmbedded</code> set to true. It is in my case. My application also has the permission <code>android.permission.INJECT_EVENTS</code> (and is built as a system application, with the ROM certificate and installed in <code>/system/priv-app</code>)</p>
  
  <p>Now, for the problem: when I call <code>startActivity</code>, the inner activity is displayed as a new activity on the stack, like any standard <code>Context.startActivity</code> call would do (the <code>ActivityView.startActivity</code> method actually does exactly that, but adds some options to the bundle before that, to display the activity on a virtual display). I also have a system Toast displayed that tells me that my <code>App does not support launch on secondary displays</code>.</p>
  
  <p>In regard to this Toast, I tried giving my application the <code>android.permission.CAPTURE_SECURE_VIDEO_OUTPUT</code> permission, to no help.</p>
  
  <p>I'm probably missing something related to the virtual display, but I can't see what…</p>
  
  <p>(I know <code>ActivityView</code> is hidden, and that actually could be a bug, I'm just being curious of what it can or cannot do.)</p>