Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Setting MainPage multiple times

$
0
0

I have an simple application with two pages. On start, I set the MainPage property to a page, like:

MainPage = new StartPage();

From the StartPage the user can go forward to the second page. I don't want a navigation page so I just change the MainPage to the new page, like:

Application.Current.MainPage  = new WebViewPage(url);

This works fine. But I want to allow the user to go back (signing out) to the first StartPage. But when I try to do this by setting the MainPage property again the app crashes on Android.

Application.Current.MainPage  = new StartPage();

Do I have to do this another way? The stack trace looks like this...

09-09 15:43:36.776 E/mono    ( 7281): Unhandled Exception:
09-09 15:43:36.776 E/mono    ( 7281): Android.Util.AndroidRuntimeException: Exception of type 'Android.Util.AndroidRuntimeException' was thrown.
referenceTable GDEF length=670 1
referenceTable GSUB length=7202 1
referenceTable GPOS length=24560 1
referenceTable head length=54 1
09-09 15:43:36.776 E/mono    ( 7281):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/1978/f98871a9/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61 
09-09 15:43:36.776 E/mono    ( 7281):   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod) [0x00083] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1010 
09-09 15:43:36.776 E/mono    ( 7281):   at Android.Views.ViewGroup.RemoveAllViews () [0x00058] in /Users/builder/data/lanes/1978/f98871a9/source/monodroid/src/Mono.Android/platforms/android-22/src/generated/Android.Views.ViewGroup.cs:4526 
09-09 15:43:36.776 E/mono    ( 7281):   at Xamarin.Forms.Platform.Android.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x0000a] in <filename unknown>:0 
09-09 15:43:36.776 E/mono    ( 7281):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.InternalSetPage (Xamarin.Forms.Page page) [0x00027] in <filename unknown>:0 
09-09 15:43:36.776 E/mono    ( 7281):   at Xamarin.Forms.Platform.Android.FormsApplicationActivity.AppOnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x0001e] in <filename unknown>:0 
09-09 15:43:36.776 E/mono    ( 7281):   at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00012] in <filename unknown>:0 
09-09 15:43:36.776 E/mono    ( 7281):   at Xamarin.Forms.Application.set_MainPage (Xamarin.Forms.Page value) [0x0008b] in <filename unknown>:0 

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>