Home | History | Annotate | only in /developers/samples/android/ui/window/DragAndDropAcrossApps
Up to higher level directory
NameDateSize
build.gradle21-Oct-2016878
buildSrc/21-Oct-2016
DragSource/21-Oct-2016
DropTarget/21-Oct-2016
gradle/21-Oct-2016
gradlew21-Oct-20165K
gradlew.bat21-Oct-20162.3K
README.md21-Oct-20163.7K
screenshots/21-Oct-2016
settings.gradle21-Oct-2016659
template-params.xml21-Oct-20164.4K

README.md

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