Seems to work on the emulator, don't know what happens with actual device until it gets some charge:
[Activity (Label = "RuntimeActivity", MainLauncher = true)]
public class RuntimeActivity : Activity
{
private static readonly string SELECT_RUNTIME_PROPERTY = "persist.sys.dalvik.vm.lib";
private static readonly string LIB_DALVIK = "libdvm.so";
private static readonly string LIB_ART = "libart.so";
private static readonly string LIB_ART_D = "libartd.so";
override protected void OnCreate(Bundle savedInstanceState) {
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.runtime);
var tv = FindViewById<TextView>(Resource.Id.textView1);
tv.Text = getCurrentRuntimeValue ();
}
private string getCurrentRuntimeValue()
{
try
{
var systemProperties = Java.Lang.Class.ForName("android.os.SystemProperties");
try
{
var str = new Java.Lang.String();
var getMethod = systemProperties.GetMethod("get", str.Class, str.Class);
if (getMethod == null)
{
return "WTF?!";
}
try
{
var value = getMethod.Invoke(systemProperties, SELECT_RUNTIME_PROPERTY,
/* Assuming default is */"Dalvik").ToString();
if (LIB_DALVIK.Equals(value)) {
return "Dalvik";
} else if (LIB_ART.Equals(value)) {
return "ART";
} else if (LIB_ART_D.Equals(value)) {
return "ART debug build";
}
return value;
}
catch (IllegalAccessException e)
{
Log.Error(this.ToString(), e.Message);
return "IllegalAccessException";
}
catch (IllegalArgumentException e)
{
Log.Error(this.ToString(), e.Message);
return "IllegalArgumentException";
}
catch (InvocationTargetException e)
{
Log.Error(this.ToString(), e.Message);
return "InvocationTargetException";
}
}
catch (NoSuchMethodException e)
{
Log.Error(this.ToString(), e.Message);
return "SystemProperties.get(String key, String def) method is not found";
}
}
catch (ClassNotFoundException e)
{
Log.Error(this.ToString(), e.Message);
return "SystemProperties class is not found";
}
}
}