示例#1
0
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
        {
            //Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

            if (requestCode == REQUEST_SENDSMS)
            {
                if (PermissionUtil.VerifyPermissions(grantResults))
                {
                    // All required permissions have been granted, display contacts fragment.
                    Snackbar.Make(layout, " Permissions have been granted. ", Snackbar.LengthShort).Show();
                    var phone       = phoneNum.Text;
                    var message     = sms.Text;
                    var piSent      = PendingIntent.GetBroadcast(this, 0, new Intent("SMS_SENT"), 0);
                    var piDelivered = PendingIntent.GetBroadcast(this, 0, new Intent("SMS_DELIVERED"), 0);
                    _smsManager.SendTextMessage(phone, null, message, piSent, piDelivered);
                }
                else
                {
                    Log.Info(TAG, " permissions were NOT granted.");
                    Snackbar.Make(layout, "Permissions were not granted.", Snackbar.LengthShort).Show();
                }
            }

            base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
 public static void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
 {
     if (requestCode == ContactServiceDroid.RequestContacts)
     {
         if (PermissionUtil.VerifyPermissions(grantResults))
         {
             contactPermissionTcs.TrySetResult(true);
         }
         else
         {
             contactPermissionTcs.TrySetResult(false);
         }
     }
 }
示例#3
0
 public static void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
 {
     if (requestCode == RequestBluetooth)
     {
         if (PermissionUtil.VerifyPermissions(grantResults))
         {
             contactPermissionTcs.TrySetResult(true);
         }
         else
         {
             contactPermissionTcs.TrySetResult(false);
         }
     }
 }
示例#4
0
 public static void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
 {
     if (requestCode == ContactsService.RequestContacts)
     {
         // We have requested multiple permissions for contacts, so all of them need to be
         // checked.
         if (PermissionUtil.VerifyPermissions(grantResults))
         {
             // All required permissions have been granted, display contacts fragment.
             contactPermissionTcs.TrySetResult(true);
         }
         else
         {
             contactPermissionTcs.TrySetResult(false);
         }
     }
 }
示例#5
0
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
        {
            if (requestCode == REQUEST_CAMERA)
            {
                // Received permission result for camera permission.
                Log.Info(this.Title.ToString(), "Received response for Camera permission request.");

                // Check if the only required permission has been granted
                if (grantResults.Length == 1 && grantResults[0] == Permission.Granted)
                {
                    // Camera permission has been granted, preview can be displayed
                    Log.Info(this.Title.ToString(), "CAMERA permission has now been granted. Showing preview.");
                    // Snackbar.Make(layout, Resource.String.permision_available_camera, Snackbar.LengthShort).Show();
                }
                else
                {
                    Log.Info(this.Title.ToString(), "CAMERA permission was NOT granted.");
                    //Snackbar.Make(layout, Resource.String.permissions_not_granted, Snackbar.LengthShort).Show();
                }
            }
            else if (requestCode == REQUEST_WriteExternalStorage)
            {
                Log.Info(this.Title.ToString(), "Received response for contact permissions request.");

                // We have requested multiple permissions for contacts, so all of them need to be
                // checked.
                if (PermissionUtil.VerifyPermissions(grantResults))
                {
                    // All required permissions have been granted, display contacts fragment.
                    //Snackbar.Make(layout, Resource.String.permision_available_contacts, Snackbar.LengthShort).Show();
                }
                else
                {
                    Log.Info(this.Title.ToString(), "Contacts permissions were NOT granted.");
                    // Snackbar.Make(layout, Resource.String.permissions_not_granted, Snackbar.LengthShort).Show();
                }
            }
            else
            {
                base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
            }
        }
        //get result of persmissions
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
        {
            if (requestCode == REQUEST_CAMERA_WriteExternalStorage)
            {
                if (PermissionUtil.VerifyPermissions(grantResults))
                {
                    // All required permissions have been granted, display Camera.

                    takePicture();
                }
                else
                {
                    // permissions did not grant, push up a snackbar to notificate USERS
                    //Snackbar.Make(layout,"Permissions were not granted", Snackbar.LengthShort).Show();
                }
            }
            else
            {
                base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
            }
        }
示例#7
0
        //        public GodAndMe.Theme GetOperatingSystemTheme()
        //        {
        //            //Ensure the device is running Android Froyo or higher because UIMode was added in Android Froyo, API 8.0
        //            if (Build.VERSION.SdkInt >= BuildVersionCodes.Froyo)
        //            {
        //                var uiModeFlags = CrossCurrentActivity.Current.AppContext.Resources.Configuration.UiMode & UiMode.NightMask;

        //                switch (uiModeFlags)
        //                {
        //                    case UiMode.NightYes:
        //                        return GodAndMe.Theme.Dark;

        //                    case UiMode.NightNo:
        //                        return GodAndMe.Theme.Light;
        //                    default:
        //#if DEBUG
        //                        throw new NotSupportedException($"UiMode {uiModeFlags} not supported");
        //#else
        //                        return GodAndMe.Theme.Light;
        //#endif
        //                }
        //            }
        //            else
        //            {
        //                return GodAndMe.Theme.Light;
        //            }
        //        }


        /*
         * Callback received when a permissions request has been completed.
         */
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
        {
            if (requestCode == REQUEST_CONTACTS)
            {
                Console.WriteLine("Received response for contact permissions request.");

                // We have requested multiple permissions for contacts, so all of them need to be
                // checked.
                if (PermissionUtil.VerifyPermissions(grantResults))
                {
                    // All required permissions have been granted, display contacts fragment.
                }
                else
                {
                    Console.WriteLine("Contacts permissions were NOT granted.");
                }
            }
            else
            {
                base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
            }
        }
示例#8
0
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
        {
            if (requestCode == PermissionHandler.REQUEST_CONTACTS)
            {
                Log.Info(TAG, "Received response for contact permissions request.");

                if (PermissionUtil.VerifyPermissions(grantResults))
                {
                    LoaderManager.InitLoader(0, null, this);
                    //All required permissions have been granted, display contacts fragment.
                    //Snackbar.Make(layout, Resource.String.permision_available_contacts, Snackbar.LengthShort).Show();
                }
                else
                {
                    Log.Info(TAG, "Contacts permissions were NOT granted.");
                    //Snackbar.Make(layout, Resource.String.permissions_not_granted, Snackbar.LengthShort).Show();
                }
            }
            else
            {
                base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
            }
        }