Skip to content

Latest commit

 

History

History

README.md

Intent to second screen sample for Surface Duo (using C# and Xamarin)

This sample demonstrates how to cause an activity to open on the second screen (as long as it's empty, otherwise the activity will launch over the current one).

In the main activity, choose an option to start: another activity from the current app or a URL in a browser window:

Intent to second screen menu

If the launcher is still visible on the other screen, the new activity will appear there:

Intent opened on second screen

The sample uses these functions to set the intent flags required to start on the second screen if available:

void StartIntentSecondActivity()
{
    var intent = new Intent(this, typeof(SecondActivity));
    // Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT is required to launch a second activity
    // on a second display while still keeping the first activity on the first display
    // (not pausing/stopping it)
    intent.AddFlags(ActivityFlags.LaunchAdjacent | ActivityFlags.NewTask);
    StartActivity(intent);
}

void StartIntentBrowserApp(string url)
{
    var intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(url));
    intent.AddFlags(ActivityFlags.LaunchAdjacent | ActivityFlags.NewTask);
    StartActivity(intent);
}

Related links