xref: /aosp_15_r20/developers/build/prebuilts/gradle/AppShortcuts/README.md (revision d353a188ca6ec4b5eba25b5fbd7bcb8ce61322fb)
1*d353a188SXin Li
2*d353a188SXin LiAndroid AppShortcuts Sample
3*d353a188SXin Li===================================
4*d353a188SXin Li
5*d353a188SXin LiThis sample demonstrates how to use the Launcher Shortcuts API introduced in Android 7.1 (API 25).
6*d353a188SXin LiThis API allows an application to define a set of Intents which are displayed as when a user
7*d353a188SXin Lilong-presses on the app's launcher icon. Examples are given for registering both links both
8*d353a188SXin Listatically in XML, as well as dynamically at runtime.
9*d353a188SXin Li
10*d353a188SXin LiIntroduction
11*d353a188SXin Li------------
12*d353a188SXin Li
13*d353a188SXin LiYou can use the shortcuts feature in Android 7.1 (API 25) to bring users from the launcher
14*d353a188SXin Lidirectly to key actions within your app. Users simply long-press your app's launcher icon
15*d353a188SXin Lito reveal the app's shortcuts, then tap on a shortcut to jump to the associated action.
16*d353a188SXin LiThese shortcuts are a great way to engage users, and they let you surface the functionality
17*d353a188SXin Liof your app even before users launch your app.
18*d353a188SXin Li
19*d353a188SXin LiEach shortcut references an intent, each of which launches a specific action or task, and
20*d353a188SXin Liyou can create a shortcut for any action that you can express as an intent. For example, you
21*d353a188SXin Lican create intents for sending a new text message, making a reservation, playing a video,
22*d353a188SXin Licontinuing a game, loading a map location, and much more.
23*d353a188SXin Li
24*d353a188SXin LiYou can create shortcuts for your app statically by adding them to a resource file in the APK,
25*d353a188SXin Lior you can add them dynamically at runtime. Static shortcuts are ideal for common actions,
26*d353a188SXin Liand dynamic shortcuts let you highlight actions based on users' preferences, behavior, location,
27*d353a188SXin Liand so on. This sample demonstrates both types of shortcuts.
28*d353a188SXin Li
29*d353a188SXin LiYou can offer up to five shortcuts in each of your apps.
30*d353a188SXin Li
31*d353a188SXin LiAfter your app adds shortcuts, they're available on any launcher that supports them, such as the
32*d353a188SXin LiPixel launcher (the default launcher on Pixel devices), the Now launcher (the default launcher on
33*d353a188SXin LiNexus devices), and other launchers that provide support.
34*d353a188SXin Li
35*d353a188SXin LiFor more information on creating shortcuts, see the [Shortcuts to App Actions][1] developer guide.
36*d353a188SXin Li
37*d353a188SXin Li[1]: https://developer.android.com/preview/shortcuts.html
38*d353a188SXin Li
39*d353a188SXin LiPre-requisites
40*d353a188SXin Li--------------
41*d353a188SXin Li
42*d353a188SXin Li- Android SDK 27
43*d353a188SXin Li- Android Build Tools v27.0.2
44*d353a188SXin Li- Android Support Repository
45*d353a188SXin Li
46*d353a188SXin LiScreenshots
47*d353a188SXin Li-------------
48*d353a188SXin Li
49*d353a188SXin Li<img src="screenshots/screenshot-1.png" height="400" alt="Screenshot"/>
50*d353a188SXin Li
51*d353a188SXin LiGetting Started
52*d353a188SXin Li---------------
53*d353a188SXin Li
54*d353a188SXin LiThis sample uses the Gradle build system. To build this project, use the
55*d353a188SXin Li"gradlew build" command or use "Import Project" in Android Studio.
56*d353a188SXin Li
57*d353a188SXin LiSupport
58*d353a188SXin Li-------
59*d353a188SXin Li
60*d353a188SXin Li- Google+ Community: https://plus.google.com/communities/105153134372062985968
61*d353a188SXin Li- Stack Overflow: http://stackoverflow.com/questions/tagged/android
62*d353a188SXin Li
63*d353a188SXin LiIf you've found an error in this sample, please file an issue:
64*d353a188SXin Lihttps://github.com/googlesamples/android-AppShortcuts
65*d353a188SXin Li
66*d353a188SXin LiPatches are encouraged, and may be submitted by forking this project and
67*d353a188SXin Lisubmitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
68*d353a188SXin Li
69*d353a188SXin LiLicense
70*d353a188SXin Li-------
71*d353a188SXin Li
72*d353a188SXin LiCopyright 2017 The Android Open Source Project, Inc.
73*d353a188SXin Li
74*d353a188SXin LiLicensed to the Apache Software Foundation (ASF) under one or more contributor
75*d353a188SXin Lilicense agreements.  See the NOTICE file distributed with this work for
76*d353a188SXin Liadditional information regarding copyright ownership.  The ASF licenses this
77*d353a188SXin Lifile to you under the Apache License, Version 2.0 (the "License"); you may not
78*d353a188SXin Liuse this file except in compliance with the License.  You may obtain a copy of
79*d353a188SXin Lithe License at
80*d353a188SXin Li
81*d353a188SXin Lihttp://www.apache.org/licenses/LICENSE-2.0
82*d353a188SXin Li
83*d353a188SXin LiUnless required by applicable law or agreed to in writing, software
84*d353a188SXin Lidistributed under the License is distributed on an "AS IS" BASIS, WITHOUT
85*d353a188SXin LiWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
86*d353a188SXin LiLicense for the specific language governing permissions and limitations under
87*d353a188SXin Lithe License.
88