-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrag_event_drop.java
More file actions
23 lines (20 loc) · 929 Bytes
/
Copy pathdrag_event_drop.java
File metadata and controls
23 lines (20 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
case DragEvent.ACTION_DROP:
requestDragAndDropPermissions(event); //Allow items from other applications
ClipData.Item item = event.getClipData().getItemAt(0);
if (event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
...
textTarget.setText(item.getText());
} else if (event.getClipDescription().hasMimeType("application/x-arc-uri-list")) {
//Note the use of ContentResolver to resolve the Chrome OS content URI
Uri contentUri = item.getUri();
ParcelFileDescriptor parcelFileDescriptor;
try {
parcelFileDescriptor = getContentResolver().openFileDescriptor(contentUri, "r");
} catch (FileNotFoundException e) {
e.printStackTrace();
Log.d("DragDropDemo", "File not found.");
return false;
}
FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
...
}