Xamarin – Cannot override OnRequestPermissionsResult

早过忘川 提交于 2019-12-10 04:17:14

问题


I've got a class that extends Activity and implements IOnRequestPermissionsResultCallback.

I want to use OnRequestPermissionResult and I coded it exactly as in XamarinBlog (section Handle Permission Request) and Monodroid Github but I always get no suitable method to override error.

namespace App1
{
    class Aplication : Android.App.Activity,
                       Android.Support.V4.AppActivityCompat.IOnRequestPermissionsResultCallback
    {

        public override async void OnRequestPermissionsResult(
            int requestCode,
            string[] permissions,
            Permission[] grantResults
        ) { }

    }
}

How can I use the new Marshmallow permissions in Xamarin?


回答1:


Most likely you use wrong Permission type (there are several types named Permission in different namespaces). Try this:

class Aplication : Android.App.Activity,
    Android.Support.V4.AppActivityCompat.IOnRequestPermissionsResultCallback {

    public override async void OnRequestPermissionsResult(
        int requestCode,
        string[] permissions,
        Android.Content.PM.Permission[] grantResults
    ) {
    }
}


来源:https://stackoverflow.com/questions/39473697/xamarin-cannot-override-onrequestpermissionsresult

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!