/// <inheritdoc cref="ContextCompat.GetSystemService(Context, Java.Lang.Class)"/> public static TService GetSystemService <TService>(this Context context) where TService : class, IJavaObject { var type = typeof(TService); var cls = Java.Lang.Class.FromType(type); var service = ContextCompat.GetSystemService(context, cls).JavaCast <TService>(); if (service == null) { throw new NullReferenceException( $"ContextCompat.GetSystemService return null, type: {type}"); } return(service); }