Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8946075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:25:08+00:00 2026-06-15T12:25:08+00:00

Until now I started a LoginScreen (after the splash) at the beginning of my

  • 0

Until now I started a LoginScreen (after the splash) at the beginning of my app:

public class StartApplicationObject
        : MvxApplicationObject
        , IMvxStartNavigation
{
    public void Start()
    {
        //this.RequestNavigate<AddressSearchViewModel>();
        //this.RequestNavigate<MainScreenViewModel>();
        this.RequestNavigate<LoginViewModel>();

    }

    public bool ApplicationCanOpenBookmarks
    {
        get { return true; }
    }
}

Well, now I need to change that. On this LoginView I’m filling data from a Webservice.
That means, that I already need to set the Webservice Url (in my case in a PreferenceActivity).

So I want that PreferenceScreen, as the StartView/Activity (not the Login One Anymore).

The PreferenceActivity:

[Activity]
public class SettingsShowActivity : PreferenceActivity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        AddPreferencesFromResource(Resource.Xml.PreferenceScreen);
    }
}

I have no Idea how to accomplish this task, as the PreferenceScreen doesn’t have a ViewModel, so how to call the activity in StartApplicationObject.cs, or do I need a WorkAround?
Maybe I should also add, that I need to be able, to navigate later from the PreferenceActivity to the LoginView(Model).. well in this case also.. how to do that?

Any help would be appreciated!

EDIT:

Thx Stuart for the answer!, I tried your second approach – creating my own MvxPreferenceActivity. It looks like that:

using System;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Preferences;
using Cirrious.MvvmCross.Android.Interfaces;
using Cirrious.MvvmCross.ExtensionMethods;
using Cirrious.MvvmCross.Interfaces.ServiceProvider;
using Cirrious.MvvmCross.Interfaces.ViewModels;
using Cirrious.MvvmCross.Platform.Diagnostics;

namespace INMobileCRM4Android
{
    public abstract class MvxPreferenceActivity<TViewModel>
    : PreferenceActivity
    , IMvxAndroidView<TViewModel>
    , IMvxServiceConsumer<IMvxIntentResultSink>
    where TViewModel : class, IMvxViewModel
    {
        protected MvxPreferenceActivity()
        {
            IsVisible = true;
        }

        #region Common code across all android views - one case for multiple inheritance?

        private TViewModel _viewModel;

        public Type ViewModelType
        {
            get { return typeof(TViewModel); }
        }

        public bool IsVisible { get; private set; }

        public TViewModel ViewModel
        {
            get { return _viewModel; }
            set
            {
                _viewModel = value;
                OnViewModelSet();
            }
        }

        public void MvxInternalStartActivityForResult(Intent intent, int requestCode)
        {
            base.StartActivityForResult(intent, requestCode);
        }

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            this.OnViewCreate();
        }

        protected override void OnDestroy()
        {
            this.OnViewDestroy();
            base.OnDestroy();
        }

        protected override void OnNewIntent(Intent intent)
        {
            base.OnNewIntent(intent);
            this.OnViewNewIntent();
        }

        protected abstract void OnViewModelSet();

        protected override void OnResume()
        {
            base.OnResume();
            IsVisible = true;
            this.OnViewResume();
        }

        protected override void OnPause()
        {
            this.OnViewPause();
            IsVisible = false;
            base.OnPause();
        }

        protected override void OnStart()
        {
            base.OnStart();
            this.OnViewStart();
        }

        protected override void OnRestart()
        {
            base.OnRestart();
            this.OnViewRestart();
        }

        protected override void OnStop()
        {
            this.OnViewStop();
            base.OnStop();
        }

        public override void StartActivityForResult(Intent intent, int requestCode)
        {
            switch (requestCode)
            {
                case (int)MvxIntentRequestCode.PickFromFile:
                    MvxTrace.Trace("Warning - activity request code may clash with Mvx code for {0}", (MvxIntentRequestCode)requestCode);
                    break;
                default:
                    // ok...
                    break;
            }
            base.StartActivityForResult(intent, requestCode);
        }

        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            this.GetService<IMvxIntentResultSink>().OnResult(new MvxIntentResultEventArgs(requestCode, resultCode, data));
            base.OnActivityResult(requestCode, resultCode, data);
        }

        #endregion
    }
}

But I keep getting the following errors:

'INMobileCRM4Android.MvxPreferenceActivity<TViewModel>' does not contain a definition for 'OnViewPause' and no extension method 'OnViewPause' accepting a first argument of type 'INMobileCRM4Android.MvxPreferenceActivity<TViewModel>' could be found (are you missing a using directive or an assembly reference?)   

And this error repeats also for: this.OnViewCreate(); , this.OnViewNewIntent(); , this.OnViewNewIntent(); , this.OnViewResume(); , this.OnViewStart(); , this.OnViewRestart(); and this.OnViewStop();

And at the end, there are 3 other errors:

No overload for method 'OnViewCreate' takes 0 arguments 

For OnViewCreate() and OnViewNewIntent() ..

I took the code from you, as it was – but seems some things are absent?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:25:10+00:00Added an answer on June 15, 2026 at 12:25 pm

    You can do this outside of MvvmCross if you want to.

    Look at providing a special SplashScreen which replaces the SplashScreen – https://github.com/slodge/MvvmCross/blob/vnext/Cirrious/Cirrious.MvvmCross.Droid/Views/MvxBaseSplashScreenActivity.cs with your own functionality.

    Then in your SettingsShowActivity – when you’ve finished with your special setup – then you can trigger the MvvmCross IMvxStartNavigation operation.


    However… having said that…

    I’d probably implement this by making a ViewModel for the SettingsShowActivity and integrating this into your normal MvvmCross application flow.

    If the problem is that you need an Mvx version of PreferenceActivity then consider creating an MvxPreferenceActivity – see the answer in Insert a Monogame view inside MvvmCross monodroid Activity to help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started using virtualenv, and it was working normally until yesterday. Now, and
A while ago I started an open-source project, which for me meant (until now)
I am have started learning Rails, it was going good until now. I am
I started using vim/gvim for windows few days ago. I use notepad++ until now
I'm building a Spring web app and up until now all of my testing
Just started playing with Ruby (no IT background) and until now went it quite
Until now I've always used the ASP.NET MVC framework source for debugging ASP.NET MVC.
Until now I've been only writing console applications but I need to write a
Until now I was logging the Error message and the stack trace of an
Until now I've been used to using DAOs to retrieve information from databases. Other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.