示例#1
0
        public static async Task <PermissionStatus> RequestPermissions(this object caller, Permission permission, string dialogTitle, string dialogMessage)
        {
            var status = await CrossPermissions.Current.CheckPermissionStatusAsync(permission);

            if (status != PermissionStatus.Granted)
            {
                if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(permission))
                {
                    CoreDependencyService.GetDependency <IDialogPrompt>().ShowMessage(new Prompt()
                    {
                        Title   = dialogTitle,
                        Message = dialogMessage
                    });
                }

                var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { permission });

#if __ANDROID__
                if (Looper.MyLooper() == null)
                {
                    Looper.Prepare();
                }
#endif
                status = results[permission];
            }

            return(status);
        }
示例#2
0
 public void CloseKeyboard()
 {
     CoreDependencyService.GetDependency <IKeyboardService>().Hide();
 }