public final class

DragAndDropPermissionsCompat

extends java.lang.Object

 java.lang.Object

↳androidx.core.view.DragAndDropPermissionsCompat

Gradle dependencies

compile group: 'androidx.core', name: 'core', version: '1.15.0-alpha02'

  • groupId: androidx.core
  • artifactId: core
  • version: 1.15.0-alpha02

Artifact androidx.core:core:1.15.0-alpha02 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.core:core com.android.support:support-compat

Androidx class mapping:

androidx.core.view.DragAndDropPermissionsCompat android.support.v13.view.DragAndDropPermissionsCompat

Overview

Helper for accessing features in a backwards compatible fashion.

Learn more in the guide to using drag permissions in multi-window mode.

Summary

Methods
public voidrelease()

Revoke the permission grant explicitly.

public static DragAndDropPermissionsCompatrequest(Activity activity, DragEvent dragEvent)

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods

public static DragAndDropPermissionsCompat request(Activity activity, DragEvent dragEvent)

public void release()

Revoke the permission grant explicitly.

Source

/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.core.view;

import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX;

import android.app.Activity;
import android.os.Build;
import android.view.DragAndDropPermissions;
import android.view.DragEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;

/**
 * Helper for accessing features in {@link DragAndDropPermissions} a backwards
 * compatible fashion.
 *
 * <p>
 * Learn more in the guide to using
 * <a href="/guide/topics/ui/drag-drop#DragPermissionsMultiWindow">drag permissions in multi-window
 * mode</a>.
 * </p>
 */
public final class DragAndDropPermissionsCompat {
    private final DragAndDropPermissions mDragAndDropPermissions;

    private DragAndDropPermissionsCompat(DragAndDropPermissions dragAndDropPermissions) {
        mDragAndDropPermissions = dragAndDropPermissions;
    }

    @RestrictTo(LIBRARY_GROUP_PREFIX)
    @Nullable
    public static DragAndDropPermissionsCompat request(@NonNull Activity activity,
            @NonNull DragEvent dragEvent) {
        if (Build.VERSION.SDK_INT >= 24) {
            DragAndDropPermissions dragAndDropPermissions =
                    Api24Impl.requestDragAndDropPermissions(activity, dragEvent);
            if (dragAndDropPermissions != null) {
                return new DragAndDropPermissionsCompat(dragAndDropPermissions);
            }
        }
        return null;
    }

    /**
     * Revoke the permission grant explicitly.
     */
    public void release() {
        if (Build.VERSION.SDK_INT >= 24) {
            Api24Impl.release(mDragAndDropPermissions);
        }
    }

    @RequiresApi(24)
    static class Api24Impl {
        private Api24Impl() {
            // This class is not instantiable.
        }

        static DragAndDropPermissions requestDragAndDropPermissions(Activity activity,
                DragEvent event) {
            return activity.requestDragAndDropPermissions(event);
        }

        static void release(DragAndDropPermissions dragAndDropPermissions) {
            dragAndDropPermissions.release();
        }
    }
}