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 is being chased by zombies.

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 sleeping in.

Drag-and-Drop, Between Apps

The preview of this section is in the process of being translated from its native Klingon.

Detecting Cross-App Drag Events

The preview of this section was abducted by space aliens.

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 is sleeping in.

Dragging and Dropping Simple Stuff

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

Multi-Action Drag-and-Drop

The preview of this section was fed to a gremlin, after midnight.

Nested Drop Targets

The preview of this section is unavailable right now, but if you leave your name and number at the sound of the tone, it might get back to you (BEEEEEEEEEEEEP!).

Pondering Standards

The preview of this section is unavailable right now, but if you leave your name and number at the sound of the tone, it might get back to you (BEEEEEEEEEEEEP!).

Pondering Accessibility

The preview of this section left for Hollywood to appear in a reality TV show.