Skip to content

Commit

Permalink
docs(android): added static shortcut info
Browse files Browse the repository at this point in the history
  • Loading branch information
jquick-axway authored and sgtcoolguy committed Aug 6, 2020
1 parent ff83583 commit 59f313a
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion apidoc/Titanium/UI/ShortcutItem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,54 @@ description: |
Use the <Titanium.UI.createShortcutItem> method to create a shortcut item and pass it to
the <Titanium.UI.Shortcut.add> method to add it to the application.
#### iOS static shortcuts
#### Android Static Shortcuts
Google documents how to add static shortcuts
[here](https://developer.android.com/guide/topics/ui/shortcuts/creating-shortcuts#static).
In the `tiapp.xml` file, you will need to add a shortcuts `<meta-data/>` element to your main activity.
``` xml
<ti:app>
<android>
<manifest>
<application>
<activity android:name=".<Yourapplicationname>Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts"/>
</activity>
</application>
</manifest>
</android>
</ti:app>
```
You will also need to create a `shortcuts.xml` file as shown below, defining all of the app's static shortcuts.
This file must reside in the Titanium project's `./platform/android/res/xml` folder. Note that XML attributes
`icon`, `shortcutShortLabel`, `shortcutLongLabel`, and `shortcutDisabledMessage` must be defined as string
resources under the project's `i18n` folders or `./platform/android/res/values` folders.
Attributes `targetPackage` and `targetClass` need to be set to your project id and app name.
``` xml
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="my_unique_string_id"
android:enabled="true"
android:icon="@drawable/my_shortcut_icon"
android:shortcutShortLabel="@string/my_shortcut_short_label"
android:shortcutLongLabel="@string/my_shortcut_long_label"
android:shortcutDisabledMessage="@string/my_shortcut_disabled_message">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="<id_from_tiapp_xml>"
android:targetClass="<id_from_tiapp_xml>.<Yourapplicationname>Activity" />
<categories android:name="android.shortcut.conversation" />
</shortcut>
<!-- Add more shortcuts here. -->
</shortcuts>
```
#### iOS Static Shortcuts
Static shortcut items can be set in the `<ios>` section of the `tiapp.xml` before launching the app.
Here is an example how to create static application shortcuts in the `tiapp.xml`:
Expand Down

0 comments on commit 59f313a

Please sign in to comment.