Example #1
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);

                if (requestCode == 8520 && AppTools.CheckPictureInPictureAllowed(this))
                {
                    UserDetails.PipIsChecked = true;
                    MainSettings.SharedData.Edit().PutBoolean("picture_in_picture_key", UserDetails.PipIsChecked).Commit();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        //General >> PictureInPicture
        private void PictureInPicturePerfOnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs e)
        {
            try
            {
                if (e.Handled)
                {
                    SwitchPreferenceCompat etp = (SwitchPreferenceCompat)sender;
                    var value = e.NewValue.ToString();
                    etp.Checked              = Boolean.Parse(value);
                    SPictureInPicture        = etp.Checked;
                    UserDetails.PipIsChecked = etp.Checked;

                    if (!AppTools.CheckPictureInPictureAllowed(ActivityContext) && SPictureInPicture)
                    {
                        var intent = new Intent("android.settings.PICTURE_IN_PICTURE_SETTINGS", Android.Net.Uri.Parse("package:" + ActivityContext.PackageName));
                        ActivityContext.StartActivityForResult(intent, 8520);
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }