[Xamarin] 에러 : Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag
C#/Xamarin Maui 2020. 6. 18. 00:23728x90
728x170
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
그리드형
'C# > Xamarin Maui' 카테고리의 다른 글
[Xamarin] Android - WebView 에서 ERR_CLEARTEXT_NOT_PERMITTED 오류 (0) | 2020.07.10 |
---|---|
[Xamarin] ITMS-90101 에러 (0) | 2020.07.07 |
[Xamarin] 에러 : Android.OS.FileUriExposedException / Failed to find configured root that contains (0) | 2020.06.18 |
[Xamarin.Android] Xamarin.Forms.Forms.Context 바꾸기 (0) | 2020.06.16 |
[Xamarin] Import DB File (0) | 2020.06.01 |