Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are three basic options:</p> <p><strong>1</strong>. Add the platform specific services in your UI project and then register them in an override during setup - which override you use depends on when your services are needed, but for most cases you can just use the <code>InitializeLastChance</code> override which gets called at the end of initialization:</p> <pre class="lang-java prettyprint-override"><code>protected override void InitializeLastChance() { this.RegisterServiceInstance&lt;IMyService&gt;(new SingletonMyService()); this.RegisterServiceType&lt;IMyService2, PerCallService2&gt;(); base.InitialiseLastChance(); } </code></pre> <p>If 'last chance' is too late for your service - if you need the service during the core app startup - then you can override any initialisation step after <code>InitializeIoC</code> - e.g. <code>InitializeFirstChance</code>. For the list and order of initialisation steps, see <code>InitializePrimary</code> and <code>InitializeSecondary</code> in <a href="https://github.com/slodge/MvvmCross/blob/vnext/Cirrious/Cirrious.MvvmCross/Platform/MvxBaseSetup.cs" rel="nofollow noreferrer">MvxBaseSetup.cs</a></p> <p><strong>2</strong>. Add the platform specific registration in some other bit of the UI code - e.g. in the constructor for a specific View (this option isn't used much... but you could use it in some odd cases, if you wanted to...)</p> <p><strong>3</strong>. Use a plugin - all plugins are is a wrapper around IoC. Plugins have the disadvantage that they add some development overhead (you have to add the separate projects and the plugin boilerplate files), but they have the advantages that they can be reused across apps and it's easier to write test apps and test harnesses for them. For more info on plugins, see <a href="https://stackoverflow.com/questions/12564272/making-mono-cross-platform-support-for-task-intent">Making mono cross platform support for Task/Intent</a> and see <a href="http://slodge.blogspot.co.uk/2012/10/build-new-plugin-for-mvvmcrosss.html" rel="nofollow noreferrer">http://slodge.blogspot.co.uk/2012/10/build-new-plugin-for-mvvmcrosss.html</a></p> <hr> <p>My general advice - start with the first option and migrate out to a plugin if you want to reuse the code in later projects...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload