The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


Drag and Drop

Desktop applications have long offered drag-and-drop, both within and between applications. Android has supported this for quite some time, but you could only drag and drop within a single activity. As a result, this was not especially popular.

However, starting in Android 7.0, you can drag and drop between applications, so long as their windows are visible in a multi-window environment. Not only does this make drag-and-drop more compelling in general, but in a freeform multi-window environment, users will expect Android apps to behave like their desktop counterparts. Hence, users will expect drag-and-drop capabilities where it makes sense.

In this chapter, we will explore Android’s drag-and-drop facility, including how to perform it between separate applications.

Prerequisites

Understanding this chapter requires that you have read the core chapters of this book, as well as the chapter on the clipboard.

One example uses RecyclerView, so reviewing that chapter is a good idea. Similarly, one sample uses StreamProvider, so you may wish to read the section on it as well.

The Scope of Drag and Drop

The preview of this section was abducted by space aliens.

The Pieces of Drag-and-Drop

The preview of this section was traded for a bag of magic beans.

Drag-and-Drop, within an Activity

The preview of this section is in an invisible, microscopic font.

Drag-and-Drop, Between Apps

The preview of this section was lost due to a rupture in the space-time continuum.

Detecting Cross-App Drag Events

The preview of this section was lost in the sofa cushions.

Intra-App Cross-Window Drag-and-Drop

The preview of this section was the victim of a MITM ('Martian in the middle') attack.

Pondering Legacy Multi-Window

The preview of this section was accidentally identified as an Android 'tasty treat' by the Cookie Monster.

Dragging and Dropping Simple Stuff

The preview of this section is en route to Mars.

Multi-Action Drag-and-Drop

The preview of this section was traded for a bag of magic beans.

Nested Drop Targets

The preview of this section is en route to Mars.

Pondering Standards

The preview of this section is off trying to sweet-talk the Khaleesi into providing us with a dragon.

Pondering Accessibility

The preview of this section is sleeping in.