Home | History | Annotate | only in /developers/samples/android/ui/window/DragAndDropAcrossApps
Up to higher level directory
NameDateSize
build.gradle21-Aug-2018878
buildSrc/21-Aug-2018
DragSource/21-Aug-2018
DropTarget/21-Aug-2018
gradle/21-Aug-2018
gradlew21-Aug-20185K
gradlew.bat21-Aug-20182.3K
README.md21-Aug-20183.9K
screenshots/21-Aug-2018
settings.gradle21-Aug-2018659
template-params.xml21-Aug-20184.4K

README.md

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