Xamarin For Android The Bad: (Part 2 of 4)
Xamarin For Android The Ugly: (Part 3 of 4)
Xamarin For Android The Conclusion: (Part 4 of 4)
Abstracting Xamarin Android SharedPreferences
The standard way to get/set SharedPreferences in Xamarin is with the following code.
Get Preference:
var shared = con.GetSharedPreferences(_preferenceName, FileCreationMode.WorldReadable);
var value = shared.All.Where(x => x.Key == key).FirstOrDefault().Value;
Set Preference:
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.
Admob with Xamarin Android Part 1: BannerAd
This will be a brief overview on how to get admob working with Xamarin.
Disclaimer
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
Admob with Xamarin Android Part 2: InterstitialAd
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.
See all tags.