zoukankan      html  css  js  c++  java
  • Xamarin 动态申请 android 权限

    if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.M)
                {
                    var permission = Permission.ReadExternalStorage;
                    if (ContextCompat.CheckSelfPermission(this, permission) != Android.Content.PM.Permission.Granted)
                    {
                        ActivityCompat.RequestPermissions(this, new String[] { permission }, 1);
                    }
                }

     一次申请多个授权

    if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.M)
                {
                    var permission = new string[] { Permission.ReadExternalStorage, Permission.WriteExternalStorage, Permission.Camera };
                    var requestPermissions = permission.Where(p => ContextCompat.CheckSelfPermission(this, p) != Android.Content.PM.Permission.Granted).ToList();
                    if (requestPermissions.Count >0 )
                        ActivityCompat.RequestPermissions(this, requestPermissions.ToArray(), 1);
    
                    var unauthorizedPermissions = permission.Where(p => ContextCompat.CheckSelfPermission(this, p) != Android.Content.PM.Permission.Granted).ToList();
                    if (unauthorizedPermissions.Count > 0)
                    {
                        Toast.MakeText(this, "部分授权未被允许", ToastLength.Long).Show();
                        return;
                    }
                }
    桂棹兮兰桨,击空明兮溯流光。
  • 相关阅读:
    电信10兆指的是多少Mbps
    keycloak ssl-required报错问题处理
    Centos7 DNS神奇的配置
    angular4套用primeng样式
    Python库大全
    jquery根据name属性的高级选择
    Js String 属性扩展
    SQLSever 触发器
    IaaS, PaaS和SaaS
    Sql Server 基础知识
  • 原文地址:https://www.cnblogs.com/nanfei/p/15045410.html
Copyright © 2011-2022 走看看