KhaiFLPM-7217 avatar image
0 Votes"
KhaiFLPM-7217 asked YonglunLiu-MSFT commented

XAMARIN FORMS (Android) - App is kicked out after successfull user validation

I have a button
<Button Text="LOGIN" Clicked="ProceedLogin" x:Name="BtnLogin" />

After button clicked, it will check my API to validate user credential, if success, then the app should navigate to the next page, but it just kicked out. Already try catch also not show any error, just KICKED OUT. Need some advise from experts here. Thank you.

 private async void ProceedLogin(object sender, EventArgs e)
         Detail user = new Detail
             usrId = myId.Text,
             usrPassword = myPwd.Text

         string getlogin = await client.GetStringAsync("*<call my webapi to validate user>*");

         Login login = JsonConvert.DeserializeObject<Login>(getlogin);
         if (login.PromptMessage != "")
             this.IsBusy = false;
             BtnLogin.IsEnabled = true;
             await DisplayAlert("", login.PromptMessage, DisplayErrorMessage("6"));
             Application.Current.Properties["isLogged"] = true;
             Application.Current.MainPage = new NavigationPage(new PageNotice());  //should go to next page



· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Could you please give us more details about this issue.

Did the issue occur when executed to Application.Current.MainPage = new NavigationPage(new PageNotice());?

If so, it might be caused by your constructor method of PageNotice.

You can try adding a single-line comment to find the wrong line.

0 Votes 0 ·


Thanks for your response.

I also suspected on the line Application.Current.MainPage = new NavigationPage(new PageNotice());
because when I point to different other pages, It can navigate successfully.

But this behavior does not happen on my XF iOS and it just fine without kicking out.

I already do try catch also does not get any error found. Do you any idea how can I know what the reason it's kicked out?

My current solution is redo the PageNotice using different page name. But I still want to know what is happening actually.

0 Votes 0 ·

You can try to convert Application.Current.MainPage = new NavigationPage(new PageNotice()); to 2 lines as the following code, and perform a single step of debugging.

var nav = new NavigationPage(new PageNotice());
Application.Current.MainPage = nav;

But this behavior does not happen on my XF iOS and it just fine without kicking out.

If there has no any error been found, you can refer to this documentation Report a problem with the Visual Studio product or installer to report this problem.

0 Votes 0 ·

May I know whether your issue has been solved or not? If not, please share it in here. We can work together to figure it out.

0 Votes 0 ·

0 Answers