Click here to Skip to main content
15,906,626 members
Articles / Mobile Apps / Xamarin

Introduction to Xamarin.Android

Rate me:
Please Sign up or sign in to vote.
4.92/5 (33 votes)
25 Aug 2014CPOL14 min read 111.6K   57   46
Introduction to Xamarin.Android


This article gives an overview of Xamarin.Android, which is a MonoDroid plug-in for Visual Studio. It allows .NET developers to build applications that target the Android platform using their existing IDE and language, therefore without having to learn Java / Eclipse. The article will go through the basics of creating a Xamarin.Android project as well explaining the key elements and project structure.


Xamarin are a California based software company who created Mono, MonoTouch and Mono for Android which are all cross-platform implementations of the Common Language Infrastructure (CLI) and Common Language Specifications (which are often referred to as Microsoft.NET)

Extracted from Visual Studio Magazine

"Monodroid is a plug-in to Visual Studio 2010. This plug-in allows developers to deploy apps to the Android Emulator running locally, as well as to a physical device connected over a USB cable and Wi-Fi. The plug-in allows MonoDroid to actively work with the rest of the Visual Studio ecosystem and integrate with the tools that developers are already using."

Using the C# language, developers are able to build native apps that can target iOS, Android and Windows Phone. They can use either Xamarin Studio (which is an IDE that is downloaded as part of the Xamarin.Android SDK) or they can use Visual Studio. Personally, I use Visual Studio as that is what I am most familiar with. For the purposes of this article, I will use Visual Studio.

This article assumes the reader is familiar with C#, Visual Studio and the .NET Framework. It also assumes that you have downloaded the Xamarin.Android SDK from the Xamarin web site. if you haven't then download it now.

Creating your First Xamarin.Android Project

To create your first Xamarin.Android project, open Visual Studio and select File -> New -> Project. In the list of installed templates on the left, select Visual C#. Underneath this, you should see Android. When selecting this, you should see a list of Xamarin.Android project templates similar to those shown in the screenshot below.

visual studio android template projects

As you can see, there are several installed Xamarin.Android project templates. For the purposes of this article, I will use the Android Application template. Give your project a meaningful name (I have named mine MyDemo but feel free to name yours whatever you like). Click OK to continue to create your project.

Project Structure

When your project has been created, you will see the following project structure.

visual studio android template projects

Expand the Resources folder and its sub-folders as in the screenshot below:

visual studio android template projects

Let's go through the various parts of the project one at a time and explain what they are and what they do. I won't go into the standard .NET elements, but instead focus on those that are specific to Xamarin.Android.

Activity1.cs - This is the default Android Activity that is created. An Activity is an Android specific entity. They define a single, focused thing that the user can perform such as adding a new customer, viewing a list of goods and so on. They have their own lifecycle and events. They are key to an Android application and so it is important to understand them.

Expand the Properties folder.

  • AndroidManifest.xml - This file defines essential information about the application to the Android system. Every Android application has one of these. This file MUST be present for the application to run as it defines such things as the name of the application to the Android system, describes the components of the application, declares permissions and defines the minimum Android API level for example.

Expand the Resources folder.

  • Drawable - This folder contains the images for your application. If your application requires different sized images for the different screen sizes, then create a sub-folder underneath here for each of the different resolutions.
  • Layout - This folder contains the Android layout (.AXML) files for your project. An Android layout file is similar to an HTML or ASPX file. It defines a single Android screen using XML syntax. Create a new layout for each screen. If your application requires different layouts for landscape or portrait, then you need to create layout-land and layout-port sub-folders respectively. By default, there is a layout created automatically for you called Main.axml. This is the UI layout that is invoked by the default Activity class mentioned earlier - Activity1.cs.
  • Values - This folder contains resource definitions that your application uses such as string values. For example, you could store the name of the application or dropdown list items in the Strings.xml file
  • Resource.Designer.cs - This file contains the class definitions for the generated IDs contained within the application. This allows application resources to be retrieved by name so the developer does not have to use the ID. The file therefore maps the application resource name to its generated ID. The file is updated each time the project is built. This file should NOT be updated by the developer.

Other files you could have underneath the Values folder include:

  • Arrays.xml
  • Colors.xml
  • Dimensions.xml
  • Styles.xml

The default entries for Strings.xml are listed below:

<?xml version="1.0" encoding="utf-8"?>
    <string name="Hello">Hello World, Click Me!</string>
    <string name="ApplicationName">MyDemo</string>

To use a Strings.xml entry from an Android layout (.AXML) file.

        android:id="@+id/txtApplicationName" />

To use a Strings.xml entry from your application code.

string applicationName = GetString(Resource.String.ApplicationName);

An example entry for Arrays.xml:

<?xml version="1.0" encoding="utf-8" ?>
  <string-array name="payment_types">
    <item>Debit Card</item>
    <item>Credit Card</item>

You can then use the payment_types array list in code as follows:

string[] paymentTypes = Resources.GetStringArray(Resource.Array.payment_types);

Other folders you could add to your project structure as your application grows in complexity could include:

  • Fragments
  • Adapters

The Activity Class

It's worth spending a little time going through the Android Activity class in a little more detail as they are fundamental to building Xamarin.Android applications.

As already mentioned, an Activity defines a single, focused thing that the user can perform. Typically, an Activity will launch an Android layout (or screen). The user interacts with a layout (.AXML) file, but the functionality is defined within the Activity.

Essentially an Activity has four states.

  • If an Activity is in the foreground, then it is active or running. Only one Activity can be running at a time. Android holds all open Activities in a stack structure where they can be popped or pushed as necessary.
  • If an Activity has lost focus but remains visible, then it is said to be paused.
  • An Activity that has been paused can be killed in scenarios such as low memory where Android needs to free up resources.
  • If an Activity is completely obscured by another Activity, then it is said to be stopped.
  • If an Activity is paused or stopped, then the Android system can remove the Activity from memory. It can do this by requesting that the Activity finishes, or it can simply kill the Activity. When the Activity is displayed again to the user, it needs to be restarted and restored to its previous state.

The following diagram (extracted from Android Developers) shows the lifecycle of an Activity.

activity lifecycle

Here is the code from the default Activity Activity1.cs.

using System;

using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace MyDemo
    [Activity(Label = "MyDemo", MainLauncher = true, Icon = "@drawable/icon")]
    public class Activity1 : Activity
        int count = 1;

        protected override void OnCreate(Bundle bundle)

            // Set our view from the "main" layout resource

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);

            button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };

Note how the Activity sets the layout (or screen) to use. It does this by invoking the function SetContentView(). Note how the layout name is passed as an argument to the function rather than its ID. The resource definition for the Main layout is contained in the file Resource.Designer.cs that was mentioned earlier. This file maps the name of the layout (which in this case is called Main) to its ID. The ID will be a unique integer value.

Note how the generated ID for the Button UI element is determined using the Android function FindViewById(). All Android UI elements have an associated ID. This ID is defined in the file Resource.Designer.cs.


We have briefly mentioned the file Resource.Designer.cs and how it maps the name of a resource to its generated ID.

When you create layouts in Android, you will add Views (a View is an Android term to refer to any UI element such as buttons, textboxes, checkboxes, etc.). You will give these UI elements a meaningful name (btnAddNewCustomer, txtCustomerSurname for example). When you need to refer to these UI elements in your application code, you determine its name via its generated ID.

The following code snippet shows the class definitions for the Id and Layout classes. Each ID is defined as a const int. This shows clearly how a UI element (layout, button, etc.) is mapped to its generated ID. Whenever you add / delete UI elements to your layouts or add / delete layouts themselves, the Resource.Designer.cs file is automatically updated when you compile the application. So there is no need to manually edit this file!

namespace MyDemo
    public partial class Resource
        public partial class Id
            // aapt resource value: 0x7f050000
            public const int MyButton = 2131034112;

            private Id()

        public partial class Layout
            // aapt resource value: 0x7f030000
            public const int Main = 2130903040;

            private Layout()

The Fragment Class

The Fragment class is another important Android element to understand when building a Xamarin.Android application. They represent a portion of the user interface in an Activity. You can think of a Fragment as a modular section of an Activity. They have their own lifecycle and events similar to an Activity. An Activity may be associated with zero or more Fragments.

In common with an Activity a Fragment can receive its own input events. You can add / remove a Fragment from an Activity or even from another Fragment at runtime. A Fragment can be added dynamically to different Activities and Fragments and therefore enable reusability.

The following diagram (extracted from Android Developers) shows the lifecycle of a Fragment.

activity lifecycle

In the following code snippet, clicking on the Notepad button invokes the Notepad Fragment (which is a screen for allowing users to enter notes into the application).

public class MyActivity : Activity
    protected override void OnCreate(Bundle bundle)
        var notePadButton = FindViewById<Button>(Resource.Id.btnNotepad);

        notePadButton.Click += (o, e) =>
                                           var ft1 = FragmentManager.BeginTransaction();
                                           var current = FragmentManager.FindFragmentById(Resource.Id.layoutFrame);
                                           ft1.Add(Frame, new Notepad());

The same code could be used to launch the Notepad Fragment from any other part of the application, whether it was from an Activity or from another Fragment. Fragments enable reusability of functionality.

The Intent Class

An Intent is a messaging object that can be used to represent an action from another component. There are three fundamental uses for an Intent.

  • To start an Activity
  • To start a Service
  • To start a Broadcast

In the following example, the Admin page Activity contains a button for launching the user group Activity screen which is responsible for assigning a user to a user group. This is achieved by using an Intent.

public class AdminPage : Activity
    protected override void OnCreate(Bundle bundle)

        var assignUserButton = FindViewById<Button>(Resource.Id.btnAssignUser);
        assignUserButton.Click += (o, e) =>
            var intent = new Intent(this, typeof(UserGroupActivity));

The Application Class

If you need to maintain state across your application, then you will need an Application class. Although it is possible to pass information to / from Activity and Fragment classes, if you have a requirement to maintain global state (such as the currently logged in user name), then you achieve this using an Application class.

public class MyApplication : Application
    public string CurrentUser = "";

Note that the class is decorated with the [Application] attribute. This is so that the necessary element is generated and added to the AndroidManifest.xml file. This ensures the class is instantiated when the application / package is created.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="" 
android:installLocation="auto" package="com.mydemo.apk" android:versionCode="1">
    <!--This line ensures the application class is instantiated automatically-->
    <application android:label="MyDemo" android:icon="@drawable/Icon"></application>

To use the Application class in your own code, you will also need to determine the current Context. In Android, the Context refers to the current state of the application / object. The Context class is also the base class for (but not limited to)

  • Activity class
  • Service class

There are several ways in which you can determine the application Context. One way is to add a method to your Application class definition that returns the Context as in the following code:

public class MyApplication : Application
    public Context GetContext()
        return ((this).ApplicationContext);

Then in your application code, you can invoke it as follows.

MyApplication application = (MyApplication)GetContext();
String username = application.GetCurrentUser();
String password = application.GetPassword();

The Android Manifest

Your Xamarin.Android application will fail to run without this file. It defines important information about your application to the Android system and it MUST be called AndroidManifest.xml. No other name can be used. It is broadly similar to a web application's web.config file.

The manifest file defines essential information including (but not limited to):

  • The name of the application
  • Describes the components of the application
  • Declares permissions
  • Defines the minimum Android API level

The diagram below shows the basic structure of the manifest file and the various elements it can contain.

<!--?xml version="1.0" encoding="utf-8"?-->

    <uses-permission />
    <permission />
    <permission-tree />
    <permission-group />
    <instrumentation />
    <uses-sdk />
    <uses-configuration />  
    <uses-feature />  
    <supports-screens />  
    <compatible-screens />  
    <supports-gl-texture />  


                <action />
                <category />
                <data />
            <meta-data />

            <intent-filter> . . . </intent-filter>
            <meta-data />

            <intent-filter> . . . </intent-filter>

            <intent-filter> . . . </intent-filter>
            <meta-data />

            <grant-uri-permission />
            <meta-data />
            <path-permission />

        <uses-library />



Below is an example of an AndroidManifest.xml file.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="" 
android:installLocation="internalOnly" android:icon="@drawable/mydemo" 
package="" android:versionCode="13" android:versionName="0">
    <uses-sdk android:targetSdkVersion="15" android:minSdkVersion="15" />
    <application android:label="MyDemo" 
    <service android:enabled="true" android:name=".BackgroundService" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.BATTERY_STATS" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" />
    <uses-permission android:name="android.permission.DEVICE_POWER" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />
    <uses-permission android:name="android.permission.FORCE_BACK" />
    <uses-permission android:name="android.permission.GET_PACKAGE_SIZE" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER" />
    <uses-permission android:name="android.permission.INSTALL_PACKAGES" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.READ_INPUT_STATE" />
    <uses-permission android:name="android.permission.READ_LOGS" />
    <uses-permission android:name="android.permission.READ_OWNER_DATA" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.SET_ALARM" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.SET_ORIENTATION" />
    <uses-permission android:name="android.permission.SET_TIME" />
    <uses-permission android:name="android.permission.SET_TIME_ZONE" />
    <uses-permission android:name="android.permission.STATUS_BAR" />
    <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.WRITE_APN_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_OWNER_DATA" />
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />

Designing and Architecting Your Application

The topic of designing and architecting a Xamarin.Android application is worthy of an article of its own, so I won't go into vast amounts of detail. Since it is more difficult to retro-fit design elements into your application afterwards, it is worth getting these firmly in place from the outset.

There are no hard and fast rules as to how you design and architect your Xamarin.Android application, but there are guidelines that you may want to consider.

Firstly, I would create subclasses of the key Android classes, i.e., ActivityBase, FragmentBase, AdapterBase and so on. Then populate these classes with the generic behaviour that is required. When creating a new Android class, ensure it inherits from your own derived version of the class. This enables reusability and leads to easier maintenance as you can change base behaviour in one place.

It is worthwhile ensuring your application is loosely coupled and that there are clear separation of concerns between the various parts of the application. An n-tier architecture is therefore worth exploring.

  • User-interface layer
  • Business rules layer
  • Data layer

In the following example, the login button invokes a method of the Activity which in turn calls a business rule to determine if the user's credentials are correct. It doesn't matter if the function invokes a web service or a data layer function (which in turn looks up the user in the local database). The important point is that there is a clear separation of concerns between the various parts of the application. The actual details of how the application is architected is for the developer to decide.

public class LoginPage : Activity
    protected override void OnCreate(Bundle bundle)

        var userNameText = FindViewById<EditText>(Resource.Id.txtUserName);
        var passwordText = FindViewById<EditText>(Resource.Id.txtPassword);
        var loginButton = FindViewById<Button>(Resource.Id.btnLogin);
        loginButton.Click += (o, e) => PressLoginButton(userNameText.Text, passwordText.Text);

    private void PressLoginButton(string username, string password)
        return BizRules.IsUserAuthenticated(username, password);

There doesn't seem to be any agreement as to whether an Android application is a good fit for the MVC design pattern. The arguments against its use include the fact that the Activity serves as both the View and the Controller and that an Activity has its own events and lifecycle that don't fit with MVC. I'm not going to go into this in any detail except to make you aware of the lack of any general agreement on the subject, and that if you wish to implement MVC, then you are free to investigate the matter further.

Unit-testing Your Application

If you are considering unit-testing your application, then you will need to architect your application in a way that supports this. You will need to make these changes from the very outset as attempting to retro-fit them afterwards will entail significant effort. Also, if you are considering targeting other mobile platforms in the future (iOS, Windows Phone), then architecting them with unit-testing in mind will ensure that this is achievable.

NUnit does not work with Xamarin.Android nor do any other unit-testing frameworks. The intent of Monodroid and Monotouch is to provide a .NET development environment that allows you to easily port business logic between different environments. As a result, you can't really test Android / iOS specific code, but you can test generic .NET business logic code. In the Monodroid projects that I write, I create three projects in the solution. One is the Android project, another is a .NET project that holds all of my non-Android business logic and the final project is an NUnit test project which tests the functionality in the aforementioned .NET business logic project. Monodroid project files cannot be tested, but .NET code files linked into Monodroid projects can be tested with whatever unit-testing framework you choose.

Your solution should therefore contain the following three projects:

  • A project which contains the Xamarin.Android specific functionality and which has been created from a Xamarin.Android project template
  • A project which contains your business logic (you can add another project for your data layer if necessary)
  • A project containing your unit tests

The key therefore to unit-testing your Xamarin.Android application is to keep all your Xamarin.Android code in a separate project. So out of the three projects in the solution described above, only one would be a Xamarin.Android project. It is by creating your solution in this way that you will be able to target other mobile platforms as you can reuse your business logic and test projects.


Hopefully, this article has given you sufficient information for you to start creating your own Xamarin.Android applications. Feel free to leave a comment if you would like me to further elaborate on anything within this article.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Technical Lead Gold-Vision CRM
United Kingdom United Kingdom
I am a professional software engineer and technical architect with over twenty years commercial development experience with a strong focus on the design and development of web and mobile applications.

I have experience of architecting scalable, distributed, high volume web applications that are accessible from multiple devices due to their responsive web design, including architecting enterprise service-oriented solutions. I have also developed enterprise mobile applications using Xamarin and Telerik Platform.

I have extensive experience using .NET, ASP.NET, Windows and Web Services, WCF, SQL Server, LINQ and other Microsoft technologies. I am also familiar with HTML, Bootstrap, Javascript (inc. JQuery and Node.js), CSS, XML, JSON, Apache Cordova, KendoUI and many other web and mobile related technologies.

I am enthusiastic about Continuous Integration, Continuous Delivery and Application Life-cycle Management having configured such environments using CruiseControl.NET, TeamCity and Team Foundation Services. I enjoy working in Agile and Test Driven Development (TDD) environments.

Outside of work I have two beautiful daughters. I am also an avid cyclist who enjoys reading, listening to music and travelling.

Comments and Discussions

QuestionIs this code still valid and updated? Pin
Exoskeletor5-Mar-20 3:05
Exoskeletor5-Mar-20 3:05 
QuestionThe application class variables are never garbage collected? Pin
Exoskeletor5-Feb-15 12:02
Exoskeletor5-Feb-15 12:02 
AnswerRe: The application class variables are never garbage collected? Pin
Dominic Burford5-Feb-15 21:46
professionalDominic Burford5-Feb-15 21:46 
GeneralRe: The application class variables are never garbage collected? Pin
Exoskeletor7-Feb-15 2:47
Exoskeletor7-Feb-15 2:47 
GeneralRe: The application class variables are never garbage collected? Pin
Dominic Burford8-Feb-15 21:54
professionalDominic Burford8-Feb-15 21:54 
GeneralRe: The application class variables are never garbage collected? Pin
Exoskeletor9-Feb-15 0:34
Exoskeletor9-Feb-15 0:34 
GeneralRe: The application class variables are never garbage collected? Pin
Dominic Burford9-Feb-15 3:25
professionalDominic Burford9-Feb-15 3:25 
GeneralRe: The application class variables are never garbage collected? Pin
Exoskeletor9-Feb-15 6:19
Exoskeletor9-Feb-15 6:19 
GeneralRe: The application class variables are never garbage collected? Pin
Dominic Burford10-Feb-15 1:27
professionalDominic Burford10-Feb-15 1:27 
GeneralRe: The application class variables are never garbage collected? Pin
Exoskeletor10-Feb-15 6:35
Exoskeletor10-Feb-15 6:35 
The thread i post on the previous post was intented to get an idea of what my app is from one post, not from the entire thread, and i wasn't sure i was allowed from you to post a very long and complicated thread, that's why i didn't wrote more.
You have already help me very much, i would never give you a thread to read every post just because it's easier for me, im sorry if this is what you understand from my previous post, it wasn't intented.

I will try to explain everything about my app and my concerns in this post:

I am creating a music player with a playlist that does the following:
The general idea is a music player that plays the surrounding sound you listen when you are for example on a forest. The way im doing it is this:
I have 2 players that play music. the one plays environment music, the other weather music.
Each track is a set of 3 tracks with different intensity level. for example, if the weather player plays rain, in the first intensity we hear low rain, in the 2nd heavy rain and in the 3rd heavy rain with thunders.

(here is an image with the interface [^])

In order for the user to change the intensity i have a progress bar for each player that change the volume in real time and the intensity on the event onstopTrackingTouch (0-33% of the bar plays the 1st intensity udio, 33-66 the 2nd and 66-100 the 3rd).
Except the progress bar, user can stop/play a track and also press next track or previous track button.
Also in the environment player it can select a subcategory (indoor or outdoor).
When we send a command to start playing a track, the command is being send on a service.

My concerns have to do about those 2 things:

1) How to store the temporary data my app needs (some lists of Playlist objects and a list of int's for the current list position)
2) Which is the best way to communicate with the service after the app has been resumed, to get the latest track playing etc. (the service will return to ints, that's enough for what i want)

How i think from my poor knowledge (not so poor because of you Smile | :) ) i have to solve those problems:

1) For this one i think the best is to retrieve the lists from the MySQL on the beggining of the app and store them to the Application class and every time a fragment need the data to retrieve them with something like this code:

public List<Playlist2> GetList(int _subCategory){
    DatabaseUpdates mydata = new DatabaseUpdates();

    if (lists [_subCategory] != null)
        return lists [_subCategory];
        return mydata.GetAllLists().Where(t => t.Type == _subCategory);

Also for the List with ints in the beggining i was thinking of storing them too on Application class but because i would like Android to store the latest position and after the user reopens the App to show the previous list positions i think i should use SharedPreferences .

2) In my opinion i have 3 ways to do this:
a) With MessageBus sending data to fragment and / or to Application class.
b) Convert service to bounded service (i would like to avoid that, it reuires a lot of code for the 3 int values i want to recieve).
c) With SharedPreferences.

With MessageBus, i think i cannot tell Android to wait for a respond from MessageBus and then to continue executing code nor i think is a good idea my App to be so depentent from MessageBus, i don't know how relaiable is.
If i cannot wait for MessageBus and load the result of the command asynchronously the User might notice a delay on the update of the interface.
SharedPreferences also might not be so reliable idea because if something happen on the service that cannot be catched with a try catch code:

play or change music.
store with SharedPreferences the new position.
store with SharedPreferences that player has stopped.

Users will have very bad experience with my code (music says is playing but it doesn't etc.)

So maybe Bounded Service is the best solution, although i would like to avoid it, so much extra code for just 2-3 ints on the OnResume Event.

Also here is the Playlist object:
public class Playlist

        [PrimaryKey, AutoIncrement]

        public int Id { get; set; }

        public int Type { get; set; }

        public String Name { get; set; }

        public String Category { get; set; }

        public String Subcategory { get; set; }

        public int ResId { get; set; }

        public int ResId2 { get; set; }

        public int ResId3 { get; set; }


Please tell me your opinion,
Thank you very much for your time, im so close for completing this App and im very excited.
GeneralRe: The application class variables are never garbage collected? Pin
Dominic Burford11-Feb-15 1:53
professionalDominic Burford11-Feb-15 1:53 
GeneralRe: The application class variables are never garbage collected? Pin
Exoskeletor11-Feb-15 5:08
Exoskeletor11-Feb-15 5:08 
GeneralRe: The application class variables are never garbage collected? Pin
Dominic Burford11-Feb-15 21:09
professionalDominic Burford11-Feb-15 21:09 
GeneralRe: The application class variables are never garbage collected? Pin
Exoskeletor12-Feb-15 2:05
Exoskeletor12-Feb-15 2:05 
QuestionHow to retain fragment arguments on fragment replace Pin
Exoskeletor17-Dec-14 14:40
Exoskeletor17-Dec-14 14:40 
AnswerRe: How to retain fragment arguments on fragment replace Pin
Dominic Burford17-Dec-14 21:22
professionalDominic Burford17-Dec-14 21:22 
GeneralRe: How to retain fragment arguments on fragment replace Pin
Exoskeletor17-Dec-14 22:03
Exoskeletor17-Dec-14 22:03 
GeneralRe: How to retain fragment arguments on fragment replace Pin
Exoskeletor20-Jan-15 7:36
Exoskeletor20-Jan-15 7:36 
QuestionXamarin is Free Pin
Tridip Bhattacharjee11-Dec-14 21:27
professionalTridip Bhattacharjee11-Dec-14 21:27 
AnswerRe: Xamarin is Free Pin
Dominic Burford12-Dec-14 2:26
professionalDominic Burford12-Dec-14 2:26 
GeneralRe: Xamarin is Free Pin
Cecil Manley26-Jul-16 23:13
Cecil Manley26-Jul-16 23:13 
SuggestionGreat article but testing is possible through NUnitLite (Android and iOS) Pin
Norbert Haberl23-Oct-14 9:49
Norbert Haberl23-Oct-14 9:49 
GeneralRe: Great article but testing is possible through NUnitLite (Android and iOS) Pin
Dominic Burford23-Oct-14 11:26
professionalDominic Burford23-Oct-14 11:26 
GeneralRe: Great article but testing is possible through NUnitLite (Android and iOS) Pin
Norbert Haberl27-Oct-14 0:32
Norbert Haberl27-Oct-14 0:32 
GeneralRe: Great article but testing is possible through NUnitLite (Android and iOS) Pin
Dominic Burford27-Oct-14 1:00
professionalDominic Burford27-Oct-14 1:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.