Book Image

Xamarin Mobile Application Development for Android, Second Edition

Book Image

Xamarin Mobile Application Development for Android, Second Edition

Overview of this book

Table of Contents (18 chapters)
Xamarin Mobile Application Development for Android Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Xamarin is built on top of Mono, an open source version of the .NET framework, based on the ECMA standards. Xamarin brings you a set of tools that includes its own C# compiler and a Common Language Runtime (CLR). The Mono framework source project is maintained by Xamarin, a San Francisco-based company (formerly by Novell and originally by Ximian). The prime intention of the Mono project was to make the .NET platform compatible with other non-Windows platforms such as Linux.

After Attachmate acquired Novell in April 2011, the future of the Mono platform was pushed into dark. A few months later, Miguel de Icaza, a former Novell employee, founded a company called Xamarin and declared to continue using the Mono platform for commercial software development. Since then, Xamarin has sponsored the Mono open source platform development and provided the commercial .NET stacks for both the iOS and Android platforms. The .NET for iOS is called MonoTouch, or Xamarin.iOS, and .NET for Android is called Mono for Android, or Xamarin.Android.

Xamarin frameworks enable developers to write cross-platform mobile applications targeting different platforms, including iOS, Android, and Windows Phone. Using Xamarin, you can develop a pure naive Android or iOS application using the C# programming language and share the application logic between the different platforms. This results in a faster development cycle and developers can leverage the existing C# and .NET programming skills, which helps reduce the learning curve to develop the mobile application.

This book is structured in a logical sequence to help C# and .NET developers to build Xamarin.Android applications from the ground up. It explains the widely used basic and advanced Android concepts, including a user interface, data storage, consuming web services, geolocation, map, camera, and the build distribution process.

This book provides the most comprehensive explanations of the basic and advanced Xamarin.Android concepts; you can precisely build with practical live examples to develop a complete working application. Over the course of this book, you will build a single application, the POIApp. With this application, we will cover all the fundamentals of Xamarin.Android to help you get stated with your own application development.

What this book covers

Chapter 1, The Anatomy of an Android App, provides an overview of the Android platform and what Android apps are composed of.

Chapter 2, The Xamarin.Android Architecture, provides an overview of the Xamarin platforms and describes how the Mono and Android runtime work together in order to allow developers to build Android apps using C#.

Chapter 3, Creating the Points of Interest App, walks you through how to set up the development environment, create a new Xamarin.Android app, and run the app in the Android emulator.

Chapter 4, Adding a List View, describes Android's AdapterView architecture and walks you through how to use ListView and create a custom adapter. This chapter also covers how to download the data asynchronously from a web service and display the response on a custom ListView.

Chapter 5, Adding a Details View, walks you through how to create a details view to display the details of POIApp, add navigation from ListView, and add actions to perform the save and delete web service operations.

Chapter 6, Making Your App Orientation-aware, walks you through how to detect the device orientation and handle application behaviors on the configuration changes.

Chapter 7, Designing for Multiple Screen Sizes, introduces you to the Android fragments and the different techniques used for managing the resources and layout to support multiple screen sizes, including Android tablets.

Chapter 8, Creating Data Storage Mechanisms, discusses a number of available data storage options in Xamarin.Android and stores the Point of Interest list fetched from a web service using the SQLite database engine to make the list accessible when a device is offline.

Chapter 9, Making POIApp Location Aware, discusses the various options that developers have in order to make their apps location-aware, and this chapter also covers how to add logic to determine a device's location, the address of a location, and display a location in the map app.

Chapter 10, Adding the Camera App Integration, discusses the various options for integrating with a device camera to capture a picture of POIApp and upload the captured photo to a web service using the HTTP multipart form upload.

Chapter 11, Publishing an App to the App Store, discusses the various options for distributing Android apps and also covers how to prepare a Xamarin.Android app for distribution.

What you need for this book

All the examples in this book can be completed using a 30-day trial version of Xamarin.Android. The examples were developed using Mac OS X (Yosemite), Xamarin Studio 5.9.3, and Xamarin.Android 5.1.3 (trial edition). Any later versions should work fine as long as they are valid Xamarin configurations. You can check the Xamarin website for specifics.

Xamarin.Android can also be used in other configurations, including Windows OS. In Windows OS, you can either use Xamarin Studio or the Visual Studio Xamarin plugin as an IDE of your choice. Using a different configuration from what was used while developing the examples of this book may result in slight variations in the screens or steps described in the book.

The examples provided in this book consume the REST web service developed in Java JAX-RS. You can deploy the web service code on your system to perform end-to-end testing, or alternatively, you can use the Apiary mock feed URLs provided in the code bundle. To deploy the web service code, you need MySQL and the Apache Tomcat™ application server.

Who this book is for

This book for C# and .NET developers with a desire to develop Android apps using their existing skill sets. This book includes a step-by-step approach to build an Android application using the Xamarin platform which will be valuable whether you're an experienced mobile developer or making your first push.

It is assumed that you have some experience in software development and are familiar with the basic object-oriented development concept and practices. An understanding of C# syntax is a requirement and a good working knowledge of C# is a distinct advantage, though it is strictly not necessary.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "These constants are placed in a Java source file named R.java."

A block of code is set as follows:

public override bool OnCreateOptionsMenu(IMenu menu)
{
    MenuInflater.Inflate(Resource.Menu.POIListViewMenu, menu);
    return base.OnCreateOptionsMenu(menu);
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

  public override Dialog OnCreateDialog (Bundle savedInstanceState)
  {
    POIDetailFragment targetFragment = (POIDetailFragment) TargetFragment;
    string poiName = Arguments.GetString(“name“);

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click on Step Over twice to watch the progress of the execution."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/B04210_Graphics.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.