Skip to content

Commit 59f313a

Browse files
jquick-axwaysgtcoolguy
authored andcommitted
docs(android): added static shortcut info
1 parent ff83583 commit 59f313a

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

apidoc/Titanium/UI/ShortcutItem.yml

+48-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,54 @@ description: |
88
Use the <Titanium.UI.createShortcutItem> method to create a shortcut item and pass it to
99
the <Titanium.UI.Shortcut.add> method to add it to the application.
1010
11-
#### iOS static shortcuts
11+
#### Android Static Shortcuts
12+
Google documents how to add static shortcuts
13+
[here](https://developer.android.com/guide/topics/ui/shortcuts/creating-shortcuts#static).
14+
15+
In the `tiapp.xml` file, you will need to add a shortcuts `<meta-data/>` element to your main activity.
16+
``` xml
17+
<ti:app>
18+
<android>
19+
<manifest>
20+
<application>
21+
<activity android:name=".<Yourapplicationname>Activity">
22+
<intent-filter>
23+
<action android:name="android.intent.action.MAIN"/>
24+
<category android:name="android.intent.category.LAUNCHER"/>
25+
</intent-filter>
26+
<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts"/>
27+
</activity>
28+
</application>
29+
</manifest>
30+
</android>
31+
</ti:app>
32+
```
33+
34+
You will also need to create a `shortcuts.xml` file as shown below, defining all of the app's static shortcuts.
35+
This file must reside in the Titanium project's `./platform/android/res/xml` folder. Note that XML attributes
36+
`icon`, `shortcutShortLabel`, `shortcutLongLabel`, and `shortcutDisabledMessage` must be defined as string
37+
resources under the project's `i18n` folders or `./platform/android/res/values` folders.
38+
Attributes `targetPackage` and `targetClass` need to be set to your project id and app name.
39+
``` xml
40+
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
41+
<shortcut
42+
android:shortcutId="my_unique_string_id"
43+
android:enabled="true"
44+
android:icon="@drawable/my_shortcut_icon"
45+
android:shortcutShortLabel="@string/my_shortcut_short_label"
46+
android:shortcutLongLabel="@string/my_shortcut_long_label"
47+
android:shortcutDisabledMessage="@string/my_shortcut_disabled_message">
48+
<intent
49+
android:action="android.intent.action.VIEW"
50+
android:targetPackage="<id_from_tiapp_xml>"
51+
android:targetClass="<id_from_tiapp_xml>.<Yourapplicationname>Activity" />
52+
<categories android:name="android.shortcut.conversation" />
53+
</shortcut>
54+
<!-- Add more shortcuts here. -->
55+
</shortcuts>
56+
```
57+
58+
#### iOS Static Shortcuts
1259
Static shortcut items can be set in the `<ios>` section of the `tiapp.xml` before launching the app.
1360
1461
Here is an example how to create static application shortcuts in the `tiapp.xml`:

0 commit comments

Comments
 (0)