Android Activity, IntentFilter, Open Forms View

borsukeborsuke Member
edited September 5 in General

I am working on user authentication in browser.

After I am successfully authenticated the browser closes and AndroidMainActivity.OnCreate() gets executed.
However application shows blank screen like no View/Page is loaded.
I am getting this Log from MVVMCross (MvvmCross.Logging.MvxLog) No ViewModel class specified for AndroidMainActivity in LoadViewModel.

So it looks like now I should navigate to some Forms Page maybe???
However the navigation does nothing for me. Probably I should do it differently but I am unable to find any article or example on how to do it.

This is how I am trying to do it now:

    [Activity(MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    [IntentFilter([] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable }, DataScheme = GdspScheme.SCHEME)]
    public class AndroidMainActivity : MvxFormsAppCompatActivity<AndroidSetup, MainApplication, App>
    {
        protected override void OnCreate(Bundle bundle)
        {
            if (Intent.Data != null)
            {
                // user authenticated

                Xamarin.Forms.Application.Current.MainPage.Navigation.PushAsync(new NavigationPage(new FormsView()));
            }
        }
    }

Answers

  • EmbapeEmbape Member ✭✭

    if you are in mainactivity you can call LoadApplication with parameter after initialize Xamarin forms

    Xamarin.Forms.Forms.Init(this, bundle);
            if (Intent.Data != null)
            {
                // user authenticated
                 LoadApplication(new App(true));
    
            }
    

    then in xamarin form in app.xaml.cs :

    public App(bool IsResisted)
        {
            InitializeComponent();
            if (IsRegisted)
            {
                MainPage = new NavigationPage(new FormsView());
            }
            else
            {
                MainPage = new NavigationPage(new MainPage());
            }
    
        }
    
Sign In or Register to comment.