How to get runtime permissions in adapter of a RecyclerView? Please see details
<p>I'm developing an app in which I need the following runtime permission to start a service:</p>

<pre><code>@TargetApi(Build.VERSION_CODES.M)
    public void startFloatyForAboveAndroidL() {
        if (!Settings.canDrawOverlays(this)) {
            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                    Uri.parse("package:" + getPackageName()));
            startActivityForResult(intent, PERMISSION_REQUEST_CODE);
        } else {
            floaty.startService();
        }
    }


    @TargetApi(Build.VERSION_CODES.M)
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == PERMISSION_REQUEST_CODE) {
            if (Settings.canDrawOverlays(this)) {
                floaty.startService();
            } else {
                Spanned message = Html.fromHtml("Please allow this permission, so &lt;b&gt;Floaties&lt;/b&gt; could be drawn.");
                Toast.makeText(this, message, Toast.LENGTH_LONG).show();
            }
        }
</code></pre>

<p>But as I'm starting the service from <code>bindView()</code> of the adapter, I have no idea where to write this code. I 'm using <a href="https://github.com/mikepenz/FastAdapter" rel="nofollow">FastAdapter</a> here.</p>

<p>Here's <code>HRequest.java</code> file's code:</p>

<pre><code>public class HRequest extends AbstractItem&lt;HRequest, HRequest.ViewHolder&gt; {

        public String imageURL;

        public HRequest() {

        }

        public HRequest(String imageURL) {
            this.imageURL = imageURL;
        }

        // Fast Adapter methods
        @Override
        public int getType() {
            return R.id.recycler_view;
        }
        @Override
        public int getLayoutRes() {
            return R.layout.h_request_list_row;
        }
        @Override
        public void bindView(ViewHolder holder) {
            super.bindView(holder);

            holder.imageURL.setText(imageURL);

        }
        // Manually create the ViewHolder class
        protected static class ViewHolder extends RecyclerView.ViewHolder {

            TextView imageURL;

            public ViewHolder(View itemView) {
                super(itemView);
                imageURL = (TextView)itemView.findViewById(R.id.imageURL);

if (!imageURL.getText().toString().isEmpty()) {

if (imageURL.getText().toString().startsWith("https://firebasestorage.googleapis.com/") || imageURL.getText().toString().startsWith("content://")) {
                    Picasso.with(itemView.getContext())
                            .load(imageURL.getText().toString())
                            .into(homelessImage);
                } else {
                    Toast.makeText(itemView.getContext(), "some problem", Toast.LENGTH_SHORT).show();
                }

            } else {
                Toast.makeText(itemView.getContext(), "no imageUID found", Toast.LENGTH_SHORT).show();
            }

            }
        }

    }
</code></pre>

<p>Please let me know how where and how can I write this code to ask for permission and preventing the app from crashing on Android M.</p>