Learn How to develop Android Apps with Xamarin
Both iOS and Android use different programming languages and development frameworks, so it can be a real challenge to produce native apps that span both markets. They must be written separately and they have high maintenance demands, but Xamarin is perfectly capable of doing that.
This is a framework more than popular in the modern app development that allows a single app to be developed, which is then deployed in translated native code to iOS and Android.
And that’s not all! Xamarin apps share code across all platforms. To be more precise, the list includes iOS, Android, Windows and Mac with a unique shared C# codebase which has the very same language, APIs and even data structures on every single platform.
As many of you know, Xamarin.Android gives you the possibility to create native Android applications using the same UI controls that you are familiar with from Java. However, in this case, things are even better as long as you have the flexibility of a modern language (C#) along with the power of the .NET Base Class Library.
Xamarin.Android uses just-in-time compilation for runtime optimization of your app’s performance, so I am talking about apps which will be native Android APKs. You can access any Android API, so it is only up to you to create apps capable of running on Android Wear devices; and as long as Xamarin is updated with the most current APIs from Google, you have the privilege of using the latest features in your apps.
If you are tempted of such an idea, during this guide, I’ll show you what you need to download and install in order to develop applications using Xamarin.Android, but not before understanding something really important: the Xamarin.Android preview supports the Android M Preview (also known as Macadamia Nut Cookie or MNC) and includes API 22/Android 5.1 Bindings – this is an update which adds Multiple SIM Card support, as well as support for Carrier Services;
So, if you want to use Android M, you need to download:
- Xamarin.Android 5.1.77 or higher, configured with Visual Studio or Xamarin Studio; take it from here;
- Android SDK as long as Android M or higher can be installed via the Android SDK Manager; download it by using this link;
- Java JDK 1.7 which is necessary for compilation of applications; access this link to take it.
Do you need help in getting started in using the new Android M features in your app? Here’s what you should know:
Learn How to develop Android Apps with Xamarin
Runtime Permissions
Do you know that you can design your app to prompt the user for permissions at runtime (in the context of where the permissions are needed)? Like that, you can start using your app immediately and if you are confused, here’s a sample app that shows how runtime permissions work in Android M.
In order to use it:
- You have to tap the Camera or Contacts buttons in order to display a permissions request dialog;
- Grant permission in order to view Camera or Contacts fragments.
Fingerprint Authentication
You can use the new FingerPrintManager class to authenticate a user on all devices that support fingerprint scanning hardware. For a better understanding, Xamarin provides once again a sample app that shows how to use registered fingerprints when it comes to authenticating a user in your app: FingerprintDialog.
In order to use it:
- If you want to open a fingerprint authentication dialog, touch the Purchase button;
- Scan in your registered fingerprint to authenticate Chrome Custom Tabs;
- Chrome Custom Tabs gives you the chance to display websites with the power of Chrome without having your users leave your app. If you want this feature in your Xamarin.Android app, take the Chrome Custom Tabs for Xamarin.Android NuGet package.
Xamarin also offers a sample app for this case, an app that demos Chrome Custom tabs on Xamarin.Android: Xamarin.ChromeCustomTabs. Before using it, install Chrome for Android (version 44 or higher) and then:
- Install Chrome Dev;
- Enter the following code into the browser:
chrome://flags - Find Enable Hosted Mode;
- Then, tap Enable and that was all.