示例#1
0
        private void ShowPublishResult(String message, IGraphObject result, FacebookRequestError error)
        {
            String title        = null;
            String alertMessage = null;

            if (error == null)
            {
                title = GetString(Resource.String.success);
                var cls = Java.Lang.Class.ForName("hellofacebooksample.HelloFacebookSampleAcvitity_GraphObjectWithId");
                var obj = (Java.Lang.Object)result.Cast(cls);
                Java.Lang.Reflect.Method m = obj.Class.GetMethod("getId");
                String id = (String)m.Invoke(obj);
                alertMessage = GetString(Resource.String.successfully_posted_post, message, id);
            }
            else
            {
                title        = GetString(Resource.String.error);
                alertMessage = error.ErrorMessage;
            }

            new AlertDialog.Builder(this)
            .SetTitle(title)
            .SetMessage(alertMessage)
            .SetPositiveButton(Resource.String.ok, (object sender, DialogClickEventArgs e) => {})
            .Show();
        }
示例#2
0
        protected override void ShowDialog(Bundle state)
        {
            MaterialDialog.Builder builder = new MaterialDialog.Builder(context)
                                             .SetTitle(DialogTitle)
                                             .SetContent(DialogMessage)
                                             .SetIcon(DialogIcon)
                                             .SetDismissListener(this)
                                             .SetCallback(new ButtonCallback
            {
                Neutral = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Neutral);
                },
                Negative = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Negative);
                },
                Positive = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Positive);
                }
            })
                                             .SetPositiveText(PositiveButtonText)
                                             .SetNegativeText(NegativeButtonText)
                                             .SetAutoDismiss(true);

            View contentView = OnCreateDialogView();

            if (contentView != null)
            {
                OnBindDialogView(contentView);
                builder.SetCustomView(contentView, false);
            }
            else
            {
                builder.SetContent(DialogMessage);
            }

            try
            {
                PreferenceManager        pm     = PreferenceManager;
                Java.Lang.Reflect.Method method = pm.Class.GetDeclaredMethod(
                    "registerOnActivityDestroyListener",
                    Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener)));
                method.Accessible = true;
                method.Invoke(pm, this);
            }
            catch (Exception) { }

            mDialog = builder.Build();
            if (state != null)
            {
                mDialog.OnRestoreInstanceState(state);
            }
            mDialog.Show();
        }
        //Connetti da device Bond (paired)
        private void MyReceiver_Bounded_ConnectDevice_Event(BluetoothDevice obj)
        {
            BluetoothGatt g = obj.ConnectGatt(context, false, this);

            Java.Lang.Reflect.Method m = g.Class.GetMethod("refresh", new Java.Lang.Class[0]);
            if (m != null)
            {
                m.Invoke(g, new Java.Lang.Object[0]);
            }
        }
示例#4
0
 public override void OnDismiss(IDialogInterface dialog)
 {
     base.OnDismiss(dialog);
     try
     {
         PreferenceManager        pm     = PreferenceManager;
         Java.Lang.Reflect.Method method = pm.Class.GetDeclaredMethod(
             "unregisterOnActivityDestroyListener",
             Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener)));
         method.Accessible = true;
         method.Invoke(pm, this);
     }
     catch (Exception) { }
 }
示例#5
0
 private bool ResetGattCache(BluetoothGatt gatt)
 {
     Java.Lang.Reflect.Method method = gatt.Class.GetMethod("refresh", null);
     if (method != null)
     {
         try
         {
             method.Invoke(gatt, null);
             return(true);
         }
         catch (Exception ex)
         {
         }
     }
     return(false);
 }
示例#6
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);
        }
示例#7
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);
        }
示例#8
0
 public override bool OnMenuOpened(int featureId, IMenu menu)
 {
     System.Diagnostics.Debug.WriteLine(featureId);
     if (menu != null)
     {
         var javaObj   = (Java.Lang.Object)menu;
         var javaClass = javaObj.Class;
         if (javaClass.SimpleName.EndsWith("MenuBuilder"))
         {
             try
             {
                 Java.Lang.Reflect.Method m = javaClass.GetDeclaredMethod("setOptionalIconsVisible", new Java.Lang.Class[] { Java.Lang.Boolean.Type });
                 m.Accessible = true;
                 m.Invoke(javaObj, new Java.Lang.Object[] { true });
             }
             catch (Java.Lang.NoSuchFieldException e)
             {
                 System.Console.WriteLine("onMenuOpened:{0}", e.ToString());
             }
         }
     }
     return(base.OnMenuOpened(featureId, menu));
 }
        /* Called when layout is created or modified (i.e. because of device rotation changes etc.) */
        protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
        {
            if (!changed)
            {
                return;
            }
            int angle     = 0;
            int geo_angle = 0;
            //here we compute a normalized orientation independent of the device class (tablet or phone)
            //so that an angle of 0 is always landscape, 90 always portrait etc.
            var     windowmanager = _context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>();
            Display display       = windowmanager.DefaultDisplay;
            int     rotation      = (int)display.Rotation;

            if (Resources.Configuration.Orientation == Android.Content.Res.Orientation.Landscape)
            {
                switch (rotation)
                {
                case 0: angle = 0; geo_angle = 0; break;

                case 1: angle = 0; geo_angle = 270; break;

                case 2: angle = 180; geo_angle = 180; break;

                case 3: angle = 180; geo_angle = 90; break;

                default:
                    break;
                }
            }
            else
            {
                switch (rotation)
                {
                case 0: angle = 90; geo_angle = 0; break;

                case 1: angle = 270; geo_angle = 270; break;

                case 2: angle = 270; geo_angle = 180; break;

                case 3: angle = 90; geo_angle = 90; break;

                default:
                    break;
                }
            }

            int realWidth;
            int realHeight;

            if ((int)Build.VERSION.SdkInt >= 17)
            {
                //new pleasant way to get real metrics
                DisplayMetrics realMetrics = new DisplayMetrics();
                display.GetRealMetrics(realMetrics);
                realWidth  = realMetrics.WidthPixels;
                realHeight = realMetrics.HeightPixels;
            }
            else if ((int)Build.VERSION.SdkInt >= 14)
            {
                //reflection for this weird in-between time
                try
                {
                    Java.Lang.Reflect.Method mGetRawH = Display.Class.GetMethod("getRawHeight");
                    var mGetRawW = Display.Class.GetMethod("getRawWidth");
                    realWidth  = (int)mGetRawW.Invoke(display);
                    realHeight = (int)mGetRawH.Invoke(display);
                }
                catch (Exception e)
                {
                    //this may not be 100% accurate, but it's all we've got
                    realWidth  = display.Width;
                    realHeight = display.Height;
                }
            }
            else
            {
                //This should be close, as lower API devices should not have window navigation bars
                realWidth  = display.Width;
                realHeight = display.Height;
            }
            _renderer.UpdateViewport(right - left, bottom - top, angle, geo_angle);
        }
示例#10
0
        protected override void ShowDialog(Bundle state)
        {
            var mBuilder = new MaterialDialog.Builder(Context)
                           .SetTitle(DialogTitle)
                           .SetIcon(DialogIcon)
                           .SetPositiveText(PositiveButtonText)
                           .SetNegativeText(NegativeButtonText)
                           .SetDismissListener(this)
                           .SetCallback(new ButtonCallback
            {
                Positive = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Positive);
                    String value = mEditText.Text;
                    if (CallChangeListener(value) && Persistent)
                    {
                        Text = value;
                    }
                },
                Neutral = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Neutral);
                },
                Negative = (x) =>
                {
                    OnClick(x, (int)DialogButtonType.Negative);
                }
            })
                           .SetDismissListener(this);

            View layout = LayoutInflater.From(Context).Inflate(Resource.Layout.sino_droid_md_stub_inputpref, null);

            OnBindDialogView(layout);

            MDTintHelper.SetTint(mEditText, mColor);

            TextView message = layout.FindViewById <TextView>(Android.Resource.Id.Message);

            if (DialogMessage != null && DialogMessage.Length > 0)
            {
                message.Visibility = ViewStates.Visible;
                message.Text       = DialogMessage;
            }
            else
            {
                message.Visibility = ViewStates.Gone;
            }
            mBuilder.SetCustomView(layout, false);

            try
            {
                var pm = PreferenceManager;
                Java.Lang.Reflect.Method method = pm.Class.GetDeclaredMethod(
                    "registerOnActivityDestroyListener",
                    Java.Lang.Class.FromType(typeof(PreferenceManager.IOnActivityDestroyListener)));
                method.Accessible = true;
                method.Invoke(pm, this);
            }
            catch (Exception) { }

            mDialog = mBuilder.Build();
            if (state != null)
            {
                mDialog.OnRestoreInstanceState(state);
            }
            RequestInputMethod(mDialog);

            mDialog.Show();
        }
示例#11
0
 static void LogInfoToPreviewer(string message)
 {
     Java.Lang.Class          designerHost = Java.Lang.Class.FromType(typeof(ImageRenderer)).ClassLoader.LoadClass("mono.android.HostProcessConnection");
     Java.Lang.Reflect.Method reportMethod = designerHost.GetMethod("logInfo", Java.Lang.Class.FromType(typeof(Java.Lang.String)));
     reportMethod.Invoke(null, message);
 }