C#/Xamarin Maui
[Xamarin] 에러 : Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag
kjun.kr
2020. 6. 18. 00:23
728x90
Dependency 서비스를 이용해 Andriod 쪽에서 아래처럼 처리하는데
var sharingIntent = new Intent(); sharingIntent.SetAction(Intent.ActionSend); ..
var intent = Intent.CreateChooser(sharingIntent, "sharing");
Android.App.Application.Context.StartActivity(intent); |
아래와 같은 에러가 발생했습니다.
Android.Util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
이를 위해선 intent 에 아래 처리를 해주면 됩니다.
intent.SetFlags(ActivityFlags.NewTask);
var sharingIntent = new Intent(); sharingIntent.SetAction(Intent.ActionSend); ..
var intent = Intent.CreateChooser(sharingIntent, "sharing"); intent.SetFlags(ActivityFlags.NewTask);
Android.App.Application.Context.StartActivity(intent); |
728x90