You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, On Avalonia Android bleeding edge branch 11.3.999-cibuild0054104-alpha (also happens on 11.2.3 stable) the below exception
is thrown in onCreate of MainActivity under numerous circumstances,
System.InvalidOperationException: 'The control MobileMainView (Content = Grid) already has a visual parent ContentPresenter (Name = PART_ContentPresenter, Host = EmbeddableControlRoot) while trying to add it as a child of ContentPresenter (Name = PART_ContentPresenter, Host = EmbeddableControlRoot).'
when tapping the launcher icon to launch app again, when tapping notification to launch Activity both when the MainActivity is in backgroun or foreground. This happens if the root view has a single Grid or any control. We have tried various launch modes in the Android manifest singletop, single instance,singletask
but this issue will happen at some point.All flags have been tested when setting pending intents for the activity when launching from notification, the issue's ocurrence can be reduced but not eliminated which suggests there is a bug that needs to be fixed
To Reproduce
Launch MainActivity from notification
Expected behavior
Mainactivity launches without throwing exception
Avalonia version
11.2.3
OS
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
Hey there! I was experiencing similar behavior at first with my own mobile app, SubverseIM. My solution was to adjust the LaunchMode for the MainActivity class in the Android subproject to LaunchMode.SingleInstance. This seemed to prevent a duplicate call to OnCreate whenever I launched the activity from a notification.
I also had to adjust the way I initialized the notification object in order to replicate the behavior of launching the app from the home screen upon tapping the notification. Here's the relevant code:
// Configure intent for special "launcher" behaviorIntentnotifyIntent=newIntent(this,typeof(MainActivity));notifyIntent.SetAction(Intent.ActionMain);notifyIntent.AddCategory(Intent.CategoryLauncher);notifyIntent.AddFlags(ActivityFlags.NewTask);// Create PendingIntent using this instancePendingIntent?pendingIntent=PendingIntent.GetActivity(this,0,notifyIntent,PendingIntentFlags.UpdateCurrent|PendingIntentFlags.Immutable);// Setup the notification object with the PendingIntentNotificationnotif=newNotificationCompat.Builder(this,/* notif id */).SetContentIntent(pendingIntent)// make sure to set the pending intent.Build();
Thanks, we have already tried what you have done in fact using GetLaunchIntentForPackage of package manager "to replicate the behavior of launching the app from the home screen upon tapping the notification" improved things further but the bug still happens under certain sequences ie when swiping the app clear ,launching the app from an action button on notification and then after that closing the app and opening from a notification causes the exception. We cannot possibly handle every edge case ,the underlying issue needs fixing.
No problem! Fair enough, in my case I didn't have this edge case issue because my app uses a ForegroundService to stay resident in memory. I agree, it should be fixed at its source!
Cheers~
Describe the bug
Hi, On Avalonia Android bleeding edge branch 11.3.999-cibuild0054104-alpha (also happens on 11.2.3 stable) the below exception
is thrown in onCreate of MainActivity under numerous circumstances,
System.InvalidOperationException: 'The control MobileMainView (Content = Grid) already has a visual parent ContentPresenter (Name = PART_ContentPresenter, Host = EmbeddableControlRoot) while trying to add it as a child of ContentPresenter (Name = PART_ContentPresenter, Host = EmbeddableControlRoot).'
when tapping the launcher icon to launch app again, when tapping notification to launch Activity both when the MainActivity is in backgroun or foreground. This happens if the root view has a single Grid or any control. We have tried various launch modes in the Android manifest singletop, single instance,singletask
but this issue will happen at some point.All flags have been tested when setting pending intents for the activity when launching from notification, the issue's ocurrence can be reduced but not eliminated which suggests there is a bug that needs to be fixed
To Reproduce
Launch MainActivity from notification
Expected behavior
Mainactivity launches without throwing exception
Avalonia version
11.2.3
OS
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: