Sender App Example: DragAndSend


When the Dual window application sends the object except for text data, the Android permission error can be occurred since SAF (Storage Access Frameworks) of Android KitKat does not recommend it. Therefore, this document does NOT also recommend sending the object except of the text data.
For this reason, sample applications only focus on sending text drag & drop.

Android SAF (Storage Access Framework) on Kitkat
SAF provides the common Documents UI to access content. Android KitKat recommends that the application use this Documents UI for accessing the other application’s content. To implement drag and drop using Documents UI, the application need the permission, android.permission.MANAGE_DOCUMENTS. However, this permission is NOT allowed for third-party applications. Therefore, Dual window applications may not allow you to send some content, such as: images, video, and so on from one app to the other.

The sample application consists of the following files:





Main activity class

\res\layout\ activity_main.xml

Layout file for the main activity in Full screen


Layout file for the dialog


the file including string values


manifest file


Modifying the AndroidManifest.xml

The manifest file should add the following metadata to enable Dual window.

<meta-data android:name="" ①
android:name="com.lge.example.dragandsend.MainActivity" ②
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

① The metadata for application to be executed in Dual window
② If the application has the above metadata, its main/launcher activity can be included in the Dual window App Drawer.


Getting Ready

The sample application sets the main layout and retrieves views.

private Context mContext;
private AlertDialog mGuideDialog = null;
protected void onCreate(Bundle savedInstanceState) {
mContext = this.getApplicationContext();

Dealing with Notification on KitKat SAF (Storage Access Framework) for Image

1. Regarding the text data, Android framework supports text drag & drop between applications, so developers do not need to implement it.
2. Regarding the image data, the application shows the notification of SAF (Storage Access Framework) instead of drag & drop.

protected void onCreate(Bundle savedInstanceState) {
Button button = (Button) findViewById(; ①

private OnClickListener clicklistener = new OnClickListener() {
public void onClick(View v) {
// Show up a noti popup describes Android Storage Access Framework
popInitialGuideUp(); ②
private void popInitialGuideUp() {
final View contents = View.inflate(mContext,, null); ③
AlertDialog.Builder builder = new
AlertDialog.Builder(MainActivity.this); ④
new DialogInterface.OnClickListener()

public void onClick(DialogInterface dialog, int which)

mGuideDialog = builder.create();;

① retrieve the button for image and set the listener
② implement the listener to show AlertDialog when users click the button
③ set the layout for the AlertDialog to show a notification for dealing with object interact exception because of the Android KitKat SAF
④ set properties of AlertDialog.