I use the following code to let the user put Android into Daydream:
final Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.systemui", "com.android.systemui.Somnambulator");
startActivity(intent);
When this code is called, my app closes, then opens, and then goes to Daydream. The issue with this is that when the screen is pinned (which is what I ultimately want), then Daydream won't work since it cannot leave the app anymore.
When Android goes to Daydream naturally (not programatically), the app does not close before it goes to Daydream, so it works even with the screen pinned.
Any ideas? I'm using Android 7 on the tablet, and Android Studio 3.0 for development. I can provide more information on request.