as Documentation Says :
If your app targets Android 7.1 (API level 25) or higher, you can define shortcuts to specific actions in your app.
- Pinned shortcuts are published at runtime and also use the ShortcutManager API. During runtime, your app can attempt to pin the shortcut, at which time the user receives a confirmation dialog asking their permission to pin the shortcut. The pinned shortcut appears in supported launchers only if the user accepts the pinning request. Link
So it should be possible to use pinned shortcuts in API level 25 itself and
above, but in the code I get Error that Calls require API level 26
.
It's happening for all PinShortcut
Methods like :
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
if (shortcutManager.isRequestPinShortcutSupported()) {
//do something
}
}
or
shortcutManager.createShortcutResultIntent(pinShortcutInfo);
these lines of code gets and API Level 26 is required error.
What is the problem? Why Document and SDK say different things? and how Can I solve this?
While the ShortcutManager was added in API 25, some of its methods were added later in API 26.
You can see on the documentation that the isRequestPinShortcutSupported and createShortcutResultIntent methods were added in API 26.
In other words: