Tuesday, 16 December 2014

Intent.FLAG_ACTIVITY_NEW_TASK in Xamarin C# Android

While trying to StartActivity from a list adapter I got this warning:
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
The way to overcome this in Java:
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
The not-so-well-documented way to acheive this using Xamarin:
intent.SetFlags(ActivityFlags.NewTask);

1 comment:

  1. Thank you! This helped me quickly!
    I expected to find this inside the Intent Object.

    ReplyDelete

Comments are moderated, so you'll have to wait a little bit before they appear!