Ejemplo n.º 1
0
        public bool IsMobileDateOn()
        {
            var  cm = (ConnectivityManager)Android.App.Application.Context.GetSystemService(Context.ConnectivityService);
            bool mobileDataEnabled = false; // Assume disabled

            try
            {
                Java.Lang.Class cmClass = Java.Lang.Class.ForName(cm.Class.Name);

                Java.Lang.Reflect.Method method = cmClass.GetDeclaredMethod("getMobileDataEnabled");
                method.Accessible = (true); // Make the method callable
                                            // get the setting for "mobile data"
                mobileDataEnabled = (bool)method.Invoke(cm);
            }
            catch (Java.Lang.Exception ex)
            { }

            return(mobileDataEnabled);
        }
Ejemplo n.º 2
0
        public static string GetProperty(string propertyName)
        {
            string result = string.Empty;

            try
            {
                Java.Lang.Class          buildClass = Java.Lang.Class.ForName("android.os.Build");
                Java.Lang.Reflect.Method getString  = buildClass.GetDeclaredMethod("getString", Java.Lang.Class.FromType(typeof(Java.Lang.String)));
                getString.Accessible = true;
                //result = getString.Invoke(null, "net.hostname").ToString();
                result = getString.Invoke(null, propertyName).ToString();
            }
            catch (Exception ex)
            {
                throw ex;

                //result = string.Empty;
            }

            return(result);
        }