Skip to content

Instantly share code, notes, and snippets.

Working on something great!

Jon Douglas JonDouglas

Working on something great!
Block or report user

Report or block JonDouglas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
JonDouglas /
Last active Oct 10, 2019
Xamarin Android Bindings Troubleshooting

Approaching a Xamarin.Android Bindings Case

1. Investigation

One of the best ways to investigate a problematic Xamarin.Android Binding is to first ensure you have the proper tooling available:

JonDouglas /
Last active Jan 29, 2019
Xamarin Android Performance

Xamarin.Android Performance Issues

1. Investigation

One of the best ways to investigate a problematic Xamarin.Android Errors is to first ensure you have the proper tooling available:

  • Diagnostic MSBuild Output Enabled(Instructions)
  • Android SDK Installed
  • Android API Level Documentation
View Activity1.cs
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using LoginScreen;
JonDouglas /
Last active Jul 28, 2017
Xamarin.Android Troubleshooting Snippets

Diagnosing JIT / AOT Timings

  1. After installing the .apk, open up an Android Device Monitor to the Logcat tab, or use adb logcat
  2. Look for a log under ActivityManager that has the message Displayed Activity: <timing>


07-28 12:48:38.356: I/ActivityManager(769): Displayed com.myapplication.App1/md58adf3f2592a7497b73592b5e766304c2.MainActivity: +1s990ms
JonDouglas / iOSBackground
Created Feb 11, 2014
iOS Background Task
View iOSBackground
using System;
using MonoTouch.UIKit;
using System.Threading.Tasks;
using System.Threading;
using System.Text;
using MonoTouch.Foundation;
namespace Demo2LongRunningTasks
partial class LongRunningTaskViewController : UIViewController
JonDouglas /
Created Mar 10, 2016
Xamarin.Android Install as System Application

Xamarin.Android Installing APK as System Application

Ideally if you took a Release .apk, anything in the lib/ABI should go into the respective /system/lib folder.

For example with a File->New Android Project

If I created a Release Aligned .apk, I should be able to extract it and view the following:


JonDouglas /
Last active Aug 19, 2016
View whatthreadami.cs
Thread uiThread;
uiThread = Thread.CurrentThread; //Ensure this is called during a Main/UI thread call
void WhatThreadAmI([CallerMemberName] string method = "", [CallerLineNumber] int line = 0)
Console.WriteLine($"{method} - {line}" {IsMainThread}");
Code Name Version API Level Release Date
None 1.0 1 2008-09-23
None 1.1 2 2009-02-09
Cupcake 1.5 3 2009-04-27
Donut 1.6 4 2009-09-15
Eclair 2.0-2.1 5-7 2009-10-26
Froyo 2.2-2.2.3 8 2010-05-20
Gingerbread 2.3-2.3.7 9-10 2010-12-06
Honeycomb 3.0-3.2.6 11-13 2011-02-22
View gist:b9fa806f40365acf3cbb
Platform Specific renderers can be found in the following namespaces:
iOS: Xamarin.Forms.Platform.iOS
Android: Xamarin.Forms.Platform.Android
Windows Phone: Xamarin.Forms.Platform.WinPhone
Base Renderer
To start with, all renders usually derive from a platform specific base renderer class that in turn inherit from a platform specific control. If you want to create platform specific renderers from scratch you are probably going to be deriving them from the correct platform's base renderer class. These have been substantially standardized in version 6201 with all controls inheriting from a generic version of ViewRenderer. There is also a non-generic version that appears to be used sometimes by navigation controls. The methods on these classes are also more in line with each other than they had been but still not the same. For example the iOS version has a method called ViewOnUnfocusRequested while the Android's version of the same method is called OnUnfocusRequested.
You can’t perform that action at this time.