名称“ PermissionsImplementation”在当前上下文中不存在

时间:2018-12-12 18:46:54

标签: xamarin

当我更新Visual Studio时,这个问题在我的Xamarin项目中弹出。因此,我创建了一个新的[空白] Xamarin测试项目,以查看它是否存在,并且没有其他动作。

我使用Nuget安装了Plugin.Permissions。然后添加https://github.com/jamesmontemagno/PermissionsPlugin

指定的代码

我的MainActivity.cs现在看起来像:

using System;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace TestApp1.Droid
{
    [Activity(Label = "TestApp1", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, savedInstanceState);
            LoadApplication(new App());
        }

        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults) {
          PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
          base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
  }

}

我得到编译器错误:“名称'PermissionsImplementation'在当前上下文中不存在”

1 个答案:

答案 0 :(得分:0)

您需要添加

using Plugin.Permissions;