In case you haven't notice, this blog has not gotten updates much this summer. Some people have even noticed the overall lack of activity on my GitHub. Emails have gone, several weeks unanswered.
Just got a new phone last week, and its one of the new Nexus phones
I recently bought a Nexus 5x from our favorite search engine, Google. Incase you didn't know I am an Android fanboy, to really specify I am an apple hater. Outside of iPhones my options are *droid or Windows Phone. Every time I have used someone else's windows phone I am honestly stricken at how great it is, but I stuck with what I know and love, which is android.
As you all are aware there are a large number of Android devices in the ecosystem that is android. The flagship phones of this year seem to be the Galaxy S6, LG G4, and various other phones that are not
Nexus phones. The competitor to these phones in the Nexus line would have to be the Nexus 6p; Which is larger, and more powerful than the 5x.
My huge gripe about non nexus phones, is that they are not really Android. Well they are, but they usually come with a ton of weird apps, and a non-stock UI. The UI that google ships for Android stock is fantastic. The OS looks crisp, clean, and somewhat futuristic without being tacky. Other UI's such as TouchWiz cannot even compete, and yet these manufacturers insist on adding this experience to their phones.
Updates and security
There is no doubt that Nexus phones get updates much faster than non-nexus phones. Incase you were not aware, Nexus phones get their updates pushed directly from google. These phones often receive more updates than non-nexus phones, which have to get updated though the manufacturer, working in tandem with the carrier. Google around yourself, and find out which phones got updated to Lollipop, or even Marshmallow. Most of the nexus phones have been kept up to date.
The updates are not just about features. Updates contain security fixes. At the end of the day a Smartphone is really just a computer that can place phone calls. Like any other computer, smartphones are susceptible to hacks and can be compromised. Updates can often contain security enhancements to reduce the surface area of attack to these phones, allowing your personal information to be stored safely.
Ok so I should actually review the phone right?
The Nexus 5x is the sequel to a phone (Nexus 5) that was a cheap phone that really competed with phones twice its price. The 5x fails to live up to that a little as the specs are at best what a good phone was last year. That being said this phone is extraordinary in both performance, size, and quality.
The 5x is about as fast as most Android phones. The camera is a 12 MP camera that takes pretty solid pictures. The battery life seems to last roughly 24 hours for me just doing daily activities on the phone. The fingerprint scanner can wake the phone from sleep, and is located in the centre on the back. This is a very convenient place that is usually where my index finger lands. This Nexus phone gets GPS locks every time, and never seems to stop performing beautify. Other phones such as the 6p would probably out perform it if you sat them side by side, but day to day you wouldn't notice any slowness in the 5x. Overall I'd say its a good buy for the value.
I'd really love to see a day when manufacturers would stop putting custom UI's ontop of Android. I'd love to see a day where all Android phones get updates direct from google. Until that time we must live with what we have, which is a weird market place in Android land. iOS users do not have to worry about such things, and I believe the same needs to happen for Android.
Interested in Interstital ads, but not banner? Thats ok, but I recommend your read my first post about banner ads. The first steps, installing Google Play Services, altering your permissions, adding to your manifests files, and reviewing my github demo are located in that tutorial.
This will be a brief overview on how to get admob working with Xamarin.
I highly suggest you run this on a real phone. I'm not sure if the virtual phones can load content on the internet. I always develop on a real phone.
Sample code located in a repo at github
The standard way to get/set SharedPreferences in Xamarin is with the following code.
var shared = con.GetSharedPreferences(_preferenceName, FileCreationMode.WorldReadable); var value = shared.All.Where(x => x.Key == key).FirstOrDefault().Value;
var shared = con.GetSharedPreferences("PreferenceName", FileCreationMode.WorldWriteable); var edit = shared.Edit(); edit.PutString(key, val); edit.Commit();
The main issue I have/had with this is you often have to know what will be returned, and what type you need to save as. Usually this isn't difficult, but it adds an un-needed level of complexity.
The other major issues I have with this, is that it is quite verbose, and unnecessary. The code duplication here can be quite high.
I know, I know the very first question you ask is going to be why do you have two phones, the answer being One is for work, the other is for my personal life. Now that we are done with that subject, we can get on with the review...
Well verdict is in boys, and girls. Personally, I thought the platform needs to mature more. For those people who can pay for the business edition ($1000 USD/developer), and really prefer c#; then go for it. For most of us that can either do c# or Java; you may want to stick with Java.
C# vs. Java for Android
If Xamarin provided more in the way of automation tools, and documentation; it would be the clear winner
The fact is going straight to Java for most people is probably a must. Even if you are more comfortable with c#, finding help on the internet is much easier. As the platform matures, and more features are added hopefully things will change.
License cost deterrent
One of my biggest gripes with Xamarin is the very inflexible license schemes. You can get by with the $300 indie edition, but it is pretty clear they want people to go the $1000 business edition route.
The biggest deterrent to the Xamarin platform is the high cost of licensing.
With no sliding scale prices based on organization size, or project scope Xamarin is a tough sell (especially for open source projects).
Xamarin, does provide a student discount. They give 90% off for enterprise edition, and for those of you whom go to school this is almost a must buy. You could probably make it back with this simple formula.
Flappy bird-like animal + Mario pipes + admob = $$$
Personally I like Xamarin platform. The ability to re-use code for multiple mobile platforms can be helpful. For most of us tinkerers out there Android Studio is probably enough. For serious businesses, with a major focus on c#; Xamarin is probably the prefered method of development.
Room for improvement
Before I can fully back Xamarin I'd like to see better componants that provide more mobile platform abstraction, increased automation tools (visual studio macros could help here), and better documentation. From the activity of there web pages, I suspect all of these things are coming.
I had some problems with Xamarin. Somethings are ugly, but with plastic surgery almost anything can become beautiful.
Xamarin has its own software packages available for download. I tried a lot of them out, some were good others not so much. One of my biggest gripes was that Google Play Services currently has a bug that makes builds really slow. Other packages were either genius, or were simply unimpressive. The components have their own package manager, and it does do a decent job of keeping them in order. I have to admit though Xamarin has its own set of componants that do in-app billing, and access phone data without having to lift much of a finger.
A real put down is that only some of the components have adequate documentation. For instance for me to get admob working with play services; I had to look at the Java documentation, and try to figure out how its supposed to be done on Xamarin. This wasn't to difficult, but admob is well used. I would have assumed the documentation would have covered it, but couldn't find anything.
Visual Studio Designer
The Visual studio designer for Android at first seemed like the best thing since sliced bread! I was able to get a UI up and running in no time. Making my app work for tablets, and mobile phones alike was simple. However, once in a while it would be stubborn, and stop working. I'm not sure if it was something I was doing, but I felt like it would bomb out and I would have to restore the XAML file to continue.
The editor really isn't great for designing ListViews, working with fragments, or making something that will scale easily. Often it made things exact pixel widths instead of using dots per inch. To keep it short, I still had to do plenty of editing of the source manually (which was not too bad). Making the theme stick on the default view was a pain, until I realized that I could ignore the editor, and decorate my MainActivity with the theme I wanted to use.
[Activity(Label = "Label", MainLauncher = true, Icon = "@drawable/Icon", Theme = "@android:style/Theme.Holo.Light")]
Xamarin is a very good platform, but like everything it has parts that are not so great.
One thing that was really hard for me, was to find documentation that was newer than 2012. Android has made great strides with Ice Cream Sandwich, and Jelly Bean. New features such as fragments have breathed life into the platform.
The Xamarin documentation provides examples even with the newest features, but there is something about it that feels lacking. Almost like it was thrown together at the last minute. They have been doing webcasts to improve the knowledge out in the wild, but googling the answer to your problem just won't do. Part of the problem is that most developers write in Java, and only bigger companies can afford the hefty license fees that come with full support.
The user community was helpful at times, but I often found myself wandering though GitHub hoping my answer could be found in some mystical repo; Eventually having to study the full implementation to find the answer I needed.
Although Xamarin has a forum where helpful users help each other, there are not nearly as many people coding on Xamarin than regular Java. Figuring out how to get something complicated working, was a nightmare. I'd look at a Java implementation, and then try to translate it into its Xamarin counterpart, which sometimes was far removed than the Java code. There are some examples of Xamarin for android out there, but nothing that really delves deep into manipulating the inner workings of the phone. I saw this especially when trying to edit contacts programatically. Xamarin support seemed helpful, but far too expensive for most freelance developers. This was a pretty huge put-off. If I went the Java route my questions would be answered with a simple search of stack overflow.
Like most things Java, Android requires a lot of boilerplate. For a developer like myself, whom avoids Java this was a problem. I would have thought that Xamarin would have abstracted out more of the boilerplate than they did. On the one had, having my code look somewhat familiar when I see Java examples was nice, but on the other hand because the API is still different often the Java versions would not be close enough to fully help. My main problem with this, is if I really wanted to write boilerplate I would have used the Java libraries myself. They did make a start for this by generating the manifest file automatically, but I feel it needs to go further to fully mature this platform as a viable alternative to Java.
This will be a series of blog entries where I discuss the Xamarin platform for Android.
When I heard about Xamarin I naturally, wanted to give it a shot. Having tried Eclipse, and Android Studio for android development I was no idiot when it came to the platform. So I got a license, and did nothing with it for six months, until a few weeks ago. After only 3 days I created Ultimate Gravatar Sync. An app that sync's your contacts gravatar images to their picture in your phone.
C# with no compromise
The Xamarin platform uses mono, and some kind of voodoo bindings to the Java libraries to make it work. I wont go in depth, but the native features of the C# language are there to use. I never felt like my hands had been tied, that all of a sudden I couldn't use a library that is normally part of the GAC (Global Assembly Cache). When I needed multi-threading, System.Threading was there, and when I needed to use C# Generics I had no issues implementing them.
Manage Android Manifest files
One of the things that blew me away about the platform, was that I never had to add anything to my manifest file. For those of you whom don't know, Android requires an XML config detailing the permissions you require, and the classes you have in your application.
Simple decoration such as:
[Activity(Label = "Label", MainLauncher = true, Icon = "@drawable/Icon")]
Will Generate in your manifest file as:
<pre> <activity android:label="Label" android:name=".logoActivity" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </pre>
Adding permissions is also easy:
Using Java Libraries
Xamarin provides some kind of crazy visual studio project, that will essentially provide c# bindings to Java libraries you require. To bind Simply create a Java Binding project, adding the .Jar files, and then build. Watch the magic happen. They do note that you sometimes need to do some configuration for certain libraries, however I had no issues with the one I tried. On top of that if you really needed to, you could access the Java Native Interface for even more power.