Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
agnostic-apollo committed Sep 3, 2020
1 parent 2b60ee4 commit 25e21df
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ In Android `7.1(API 25)` new [ShortcutManager](https://developer.android.com/ref
- Dynamic shortcuts are context sensitive and are displayed by launchers like nova launcher by long pressing the app icon and only exist in android `>=7.1`. Android apps can register dynamic shortcuts with the `ShortcutManager` at runtime by sending a list of [ShortcutInfo](https://developer.android.com/reference/android/content/pm/ShortcutInfo) objects to [ShortcutManager.addDynamicShortcuts()](https://developer.android.com/reference/android/content/pm/ShortcutManager#addDynamicShortcuts(java.util.List%3Candroid.content.pm.ShortcutInfo%3E)) function. Each `ShortcutInfo` contains information like the icon, label, the real intent and any extras that will be sent when that shortcut will be requested to be launched by the launcher. These shortcuts can be queried by the launcher apps using the [LauncherApps.getShortcuts()](https://developer.android.com/reference/android/content/pm/LauncherApps#getShortcuts(android.content.pm.LauncherApps.ShortcutQuery,%20android.os.UserHandle)) function and passing the [FLAG_MATCH_DYNAMIC](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_DYNAMIC) query flag.

- Pinned shortcuts are sent by apps to the launcher when you press buttons like `Add to Home screen`, like pinning a website or chat shortcut on the launcher home.
- In android `<8`, apps can send shortcuts to be pinned to the launchers with a broadcast intent with the `com.android.launcher.action.INSTALL_SHORTCUT` action, `EXTRA_SHORTCUT_INTENT` intent extra and `EXTRA_SHORTCUT_NAME` string extra using [Context.sendBroadcast](https://developer.android.com/reference/android/content/Context#sendBroadcast(android.content.Intent)) function. The launcher apps can register a `BroadcastReceiver` with the `com.android.launcher.permission.INSTALL_SHORTCUT` permission and `com.android.launcher.action.INSTALL_SHORTCUT` action to receive these shortcuts. This is [no longer supported](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/oreo-release/services/core/java/com/android/server/am/ActivityManagerService.java#19328) in android `>=8`.
- In android `<8`, apps can send shortcuts to be pinned to the launchers with a broadcast intent with the `com.android.launcher.action.INSTALL_SHORTCUT` action, `EXTRA_SHORTCUT_INTENT` intent extra and `EXTRA_SHORTCUT_NAME` string extra using [Context.sendBroadcast()](https://developer.android.com/reference/android/content/Context#sendBroadcast(android.content.Intent)) function. The launcher apps can register a `BroadcastReceiver` with the `com.android.launcher.permission.INSTALL_SHORTCUT` permission and `com.android.launcher.action.INSTALL_SHORTCUT` action to receive these shortcuts. This is [no longer supported](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/oreo-release/services/core/java/com/android/server/am/ActivityManagerService.java#19328) in android `>=8`.
- In android `>=8`, apps can send shortcuts to be pinned to the launchers by creating a `ShortcutInfo` object and sending it to the [ShortcutManager.requestPinShortcut()](https://developer.android.com/reference/android/content/pm/ShortcutManager#requestPinShortcut(android.content.pm.ShortcutInfo,%20android.content.IntentSender)) function. The launcher apps can declare an `Activity` with the `android.content.pm.action.CONFIRM_PIN_SHORTCUT` [intent-filter](https://developer.android.com/guide/topics/manifest/intent-filter-element) to receive and confirm these shortcuts. The shortcuts owned by the launcher apps can be queried using the [LauncherApps.getShortcuts()](https://developer.android.com/reference/android/content/pm/LauncherApps#getShortcuts(android.content.pm.LauncherApps.ShortcutQuery,%20android.os.UserHandle)) function and passing the [FLAG_MATCH_PINNED](https://developer.android.com/reference/android/content/pm/LauncherApps.ShortcutQuery#FLAG_MATCH_PINNED) query flag.

Android docs are really really shitty for creating launchers, had to go through android default AOSP [launcher](https://android.googlesource.com/platform/packages/apps/Launcher3/+/refs/heads/master) [port](https://github.com/amirzaidi/Launcher3) and [Nova Launcher](https://play.google.com/store/apps/details?id=com.teslacoilsw.launcher&hl=en) source codes to figure lot of stuff out.
Expand Down

0 comments on commit 25e21df

Please sign in to comment.