MasterDe

kenneth.leekenneth.lee USMember ✭✭✭

Hi Everyone,

I am fairly new to xamarin and i have a problem with navigating between MasterDetailPages

The way my app work is that after the user logs in the user will be sent to one of the MasterDetailPages but the user is allowed to navigate to other MasterDetailPages from the MenuPage which is set to the Master for all MasterDetailPage.

The problem is that the app works fine if the clicks are done slowly with time inbetween and on a sluggy emulator but on an actual device it crashes when i double click without any exception and leaves me a stacktrace of ...

11-22 13:00:23.672 E/mono-rt ( 5477): Stacktrace:
11-22 13:00:23.672 E/mono-rt ( 5477):
11-22 13:00:23.672 E/mono-rt ( 5477): at <0xffffffff>
11-22 13:00:23.672 E/mono-rt ( 5477): at (wrapper managed-to-native) Java.Interop.NativeMethods.java_interop_jnienv_call_nonvirtual_void_method_a (intptr,intptr&,intptr,intptr,intptr,Java.Interop.JniArgumentValue) <0x0005b>
11-22 13:00:23.672 E/mono-rt ( 5477): at Java.Interop.JniEnvironment/InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference,Java.Interop.JniObjectReference,Java.Interop.JniMethodInfo,Java.Interop.JniArgumentValue
)
11-22 13:00:23.672 E/mono-rt ( 5477): at Java.Interop.JniPeerMembers/JniInstanceMethods.InvokeVirtualVoidMethod (string,Java.Interop.IJavaPeerable,Java.Interop.JniArgumentValue*)
11-22 13:00:23.672 E/mono-rt ( 5477): at Android.Views.ViewGroup.AddView (Android.Views.View)
11-22 13:00:23.672 E/mono-rt ( 5477): at Xamarin.Forms.Platform.Android.Platform.AddChild (Xamarin.Forms.VisualElement,bool) [0x00034] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Renderers\ImageRenderer.cs:43
11-22 13:00:23.672 E/mono-rt ( 5477): at Xamarin.Forms.Platform.Android.Platform.SetPage (Xamarin.Forms.Page) [0x0001d] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Renderers\FrameRenderer.cs:31
11-22 13:00:23.672 E/mono-rt ( 5477): at Xamarin.Forms.Platform.Android.FormsApplicationActivity.InternalSetPage (Xamarin.Forms.Page) [0x0001d] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Cells\TextCellRenderer.cs:56
11-22 13:00:23.672 E/mono-rt ( 5477): at Xamarin.Forms.Platform.Android.FormsApplicationActivity.AppOnPropertyChanged (object,System.ComponentModel.PropertyChangedEventArgs) [0x00016] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Cells\TextCellRenderer.cs:50
11-22 13:00:23.672 E/mono-rt ( 5477): at Xamarin.Forms.BindableObject.OnPropertyChanged (string) [0x0000a] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:137
11-22 13:00:23.672 E/mono-rt ( 5477): at Xamarin.Forms.Element.OnPropertyChanged (string) [0x00000] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\Element.cs:369
11-22 13:00:23.672 E/mono-rt ( 5477): at Xamarin.Forms.Application.set_MainPage (Xamarin.Forms.Page) [0x0008b] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\Application.cs:88
11-22 13:00:23.672 E/mono-rt ( 5477): at MyApp.MenuPage.openPage (string,Xamarin.Forms.StackLayout) [0x00011] in C:\Users\kenneth.lee\Documents\my-app\MyApp\MainMenu\MenuPage.cs:39
11-22 13:00:23.672 E/mono-rt ( 5477): at MyApp.MenuPage/<>c__DisplayClass5_0.<.ctor>b__5 () [0x00000] in C:\Users\kenneth.lee\Documents\my-app\MyApp\MainMenu\MenuPage.cs:223
11-22 13:00:23.672 E/mono-rt ( 5477): at Xamarin.Forms.Command/<>c__DisplayClass3_0.<.ctor>b__0 (object) [0x00000] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\Command.cs:36
11-22 13:00:23.672 E/mono-rt ( 5477): at Xamarin.Forms.Command.Execute (object) [0x00000] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\Command.cs:70
11-22 13:00:23.672 E/mono-rt ( 5477): at Xamarin.Forms.TapGestureRecognizer.SendTapped (Xamarin.Forms.View) [0x00018] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Core\TapGestureRecognizer.cs:42
11-22 13:00:23.672 E/mono-rt ( 5477): at Xamarin.Forms.Platform.Android.TapGestureHandler.OnTap (int) [0x00000] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\RendererFactory.cs:10
11-22 13:00:23.672 E/mono-rt ( 5477): at Xamarin.Forms.Platform.Android.InnerGestureListener.Android.Views.GestureDetector.IOnGestureListener.OnSingleTapUp (Android.Views.MotionEvent) [0x00008] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\Renderers\FormsTextView.cs:27
11-22 13:00:23.672 E/mono-rt ( 5477): at Android.Views.GestureDetector/IOnGestureListenerInvoker.n_OnSingleTapUp_Landroid_view_MotionEvent_ (intptr,intptr,intptr)
11-22 13:00:23.672 E/mono-rt ( 5477): at (wrapper dynamic-method) object.c849caa1-493e-456f-b187-76859bdd1cc4 (intptr,intptr,intptr)
11-22 13:00:23.672 E/mono-rt ( 5477): at (wrapper native-to-managed) object.c849caa1-493e-456f-b187-76859bdd1cc4 (intptr,intptr,intptr)

The function at line 39 of MenuPage is

    void openPage(string sender, StackLayout item)
    {
            App.Current.MainPage = new LandingPage(sender);
            Navigation.RemovePage(this);
    }

LandingPage Class helps decide which MasterPageDetail to create based off the sender string.

I don't have any clue how to fix this and have tried to implement work around this issue like trying to wait for the first click to finish.
If any more details are needed I would be happy to provide.
Thanks!

Answers

  • kenneth.leekenneth.lee USMember ✭✭✭

    I fixed this, there was some problems with me not threading properly and I needed to prevent other threads from reading and writing while it is in used

Sign In or Register to comment.