• Home
Name Date Size #Lines LOC

..--

DragSource/03-May-2024-1,875858

DropTarget/03-May-2024-1,716780

buildSrc/03-May-2024-3328

gradle/wrapper/03-May-2024-76

screenshots/03-May-2024-

README.mdD03-May-20243.7 KiB9773

build.gradleD03-May-2024878 2924

gradlewD03-May-20245 KiB165122

gradlew.batD03-May-20242.3 KiB9166

settings.gradleD03-May-2024659 1816

template-params.xmlD03-May-20244.4 KiB11485

README.md

1
2Android DragAndDropAcrossApps-new Sample
3===================================
4
5This sample demonstrates how data can be moved between views within an
6app or between different apps via drag and drop.
7This sample contains two separate Android applications, DragSource and
8DropTarget that show how data can be dragged and dropped between
9two separate apps.
10
11Introduction
12------------
13
14Android N introduces support for drag and drop between applications,
15augmenting the existing APIs that have enabled this within a single
16window before.
17
18To start a drag operation you need to call `View.startDragAndDrop`.
19Which gesture or action triggers this is up to you as an app developer.
20The API guide recommends doing this from
21`View.OnLongClickListener.onLongClick` and this seems to be the de-facto
22standard, but you are free to use other gestures (single tap, tap and drag
23etc).
24However, if you go for a unconventional drag start gesture, note that
25the framework implementation assumes that the pointer (touch or mouse)
26is down while the drag is starting, and the most recent touch/click
27position is used as the original position of the drag shadow.
28
29See also `android.support.v13.view.DragStartHelper` which uses different
30gestures for touch and mouse (click and drag works better for mouse
31than a long click).
32
33By default a drag and drop operation is constrained by the window
34containing the view that started the drag.
35To enable cross-window and cross-app drag and drop add
36`View.DRAG_FLAG_GLOBAL` to the flags passed to the `View.startDragAndDrop`
37call.
38
39If a Uri requiring permission grants is being sent, then the
40`android.view.View.DRAG_FLAG_GLOBAL_URI_READ` and/or the
41`android.view.View.DRAG_FLAG_GLOBAL_URI_WRITE` flags must be used also.
42To access content URIs requiring permissions on the receiving side, the target
43app needs to request the `android.view.DropPermissions` from the activity via
44`android.app.Activity.requestDropPermissions`. This permission will stay either
45until the activity is alive, or until the `release()` method is called on the
46`android.view.DropPermissions` object.
47
48Pre-requisites
49--------------
50
51- Android SDK vandroid-N
52- Android Build Tools v23.0.0
53- Android Support Repository
54
55Screenshots
56-------------
57
58<img src="screenshots/app.png" height="400" alt="Screenshot"/>
59
60Getting Started
61---------------
62
63This sample uses the Gradle build system. To build this project, use the
64"gradlew build" command or use "Import Project" in Android Studio.
65
66Support
67-------
68
69- Google+ Community: https://plus.google.com/communities/105153134372062985968
70- Stack Overflow: http://stackoverflow.com/questions/tagged/android
71
72If you've found an error in this sample, please file an issue:
73https://github.com/googlesamples/android-DragAndDropAcrossApps-new
74
75Patches are encouraged, and may be submitted by forking this project and
76submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
77
78License
79-------
80
81Copyright 2014 The Android Open Source Project, Inc.
82
83Licensed to the Apache Software Foundation (ASF) under one or more contributor
84license agreements.  See the NOTICE file distributed with this work for
85additional information regarding copyright ownership.  The ASF licenses this
86file to you under the Apache License, Version 2.0 (the "License"); you may not
87use this file except in compliance with the License.  You may obtain a copy of
88the License at
89
90http://www.apache.org/licenses/LICENSE-2.0
91
92Unless required by applicable law or agreed to in writing, software
93distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
94WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
95License for the specific language governing permissions and limitations under
96the License.
97