Do we have to do anything special to enable this feature in our app or we normally listen for Drop events
Assuming that you are using setOnDragListener()
, your app will receive drop events regardless of origin (from within your app or from another app).
Note that you will want to call requestDragAndDropPermissions()
in your ACTION_DROP
handling, so that you have rights to any content referenced in the DragEvent
. That is not necessary for in-app drop events, and it probably is not needed for simple text drop events between apps, but it becomes important for drag-and-drop of content represented by Uri
values.
Can anyone give a link to the code sample for this ?
This project has a pair of app modules. drag/
implements an activity that allows you to drag a photo from an ImageView
via a long-click gesture. drop/
implements an activity that accepts the dragged image. The image is shared via a FileProvider
.