-
Notifications
You must be signed in to change notification settings - Fork 130
Create App Shortcuts on Android 7.1
Dani Mahardhika edited this page Sep 3, 2017
·
3 revisions
Open this link, you will see 4 files, SearchShortcut.java
, ic_shortcut_favorite.xml
, ic_shortcut_search.xml
, and shortcuts.xml
. Download all of them.
- Copy file
ic_shortcut_favorite.xml
andic_shortcut_search.xml
todrawable
folder - Copy file
shortcuts.xml
toxml
folder - Copy file
SearchShortcut.java
tojava\com\your\package\name\activities\
After copying those files, open SearchShortcut.java
, you will notice there's a red mark on line 1 .
package com.dm.wallpaper.board.demo.shortcuts;
Change it to
package com.your.package.name.activities;
After that open shortcuts.xml
, take a look on line 36, 37 and 54, 55.
...
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.dm.wallpaper.board.demo"
android:targetClass="com.dm.wallpaper.board.demo.shortcuts.SearchShortcut">
</intent>
...
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.dm.wallpaper.board.demo"
android:targetClass="com.dm.wallpaper.board.demo.activities.MainActivity">
<extra
android:name="position"
android:value="1" />
</intent>
...
- Change
android:targetPackage="com.dm.wallpaper.board.demo"
with your package nameandroid:targetPackage="com.your.package.name"
. - Change
android:targetClass="com.dm.wallpaper.board.demo.shortcuts.SearchShortcut"
toandroid:targetClass="com.your.package.name.activities.SearchShortcut"
. - Change
android:targetClass="com.dm.wallpaper.board.demo.activities.MainActivity"
toandroid:targetClass="com.your.package.name.activities.MainActivity"
.
Open AndroidManifest.xml
, take a look on line 28.
...
<activity android:name="com.your.package.name.activities.SplashActivity"
android:launchMode="singleTop"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
Change it to
...
<activity android:name="com.your.package.name.activities.SplashActivity"
android:launchMode="singleTop"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@style/SplashTheme">
<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>
...
Last, add this code to AndroidManifest.xml
inside application tag.
<activity android:name="com.your.package.name.activities.SearchShortcut"
android:theme="@style/WallpaperTheme"
android:noHistory="true"
android:excludeFromRecents="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
Shortcuts is set, make sure you have a device with Android 7.1 to test it.
- Setup
- Customization: Basic → Necessary
- Customization: Advanced → Optional
- Dashboard Configuration → Optional