[英]'Intent' does not contain a definition for 'FLAG_ACTIVITY_NEW_TASK'
I have started programming an Xamarin Android App that changes the activity when the alarm goes off. 我已经开始编写Xamarin Android应用程序,该应用程序会在警报响起时更改活动。 Everywhere online everyone says to use FLAG_ACTIVITY_NEW_TASK or similar flags to call a new activity.
每个人都在网上到处说要使用FLAG_ACTIVITY_NEW_TASK或类似的标记来调用新活动。 For some reason, my Intent does not have any of those flags defined.
由于某种原因,我的意图没有定义任何这些标志。
[BroadcastReceiver(Enabled = true)]
public class AlarmReceiver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
Toast.MakeText(context, "THIS IS MY ALARM", ToastLength.Long).Show();
Intent i = new Intent();
i.SetClassName("AlarmReceiver", "AlarmActivated");
i.SetFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //error
context.StartActivity(i);
}
}
Is there a reason why this flag, or other similar flags are not defined? 为什么没有定义此标志或其他类似标志? Thanks.
谢谢。
Xamarin "C# normalizes" the Android/Java methods/properties and at times moves enums/flags into their own "sub" enums, FLAG_ACTIVITY{_XXX}
becomes an ActivityFlags
enum. Xamarin“ C#规范化”了Android / Java方法/属性,有时将枚举/标志移动到自己的“子”枚举中,
FLAG_ACTIVITY{_XXX}
变成了ActivityFlags
枚举。
So Intent.FLAG_ACTIVITY_NEW_TASK
becomes ActivityFlags.NewTask
因此
Intent.FLAG_ACTIVITY_NEW_TASK
成为ActivityFlags.NewTask
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
In my case addFlags was helped instead of setFlags 在我的情况下,使用了addFlags而不是setFlags
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.