2

Android N announced multi-window drag and drop feature, where we can drag and drop objects between activities.

This is the video of Google-IO'16 where they show the demo (9:56).

Do we have to do anything special to enable this feature in our app or we normally listen for Drop events (Assuming that I only want people to drop into my app from other apps ?

Can anyone give a link to the code sample for this ?

Rohith R
  • 1,309
  • 2
  • 17
  • 36

1 Answers1

3

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491