I was trying to create app shortcut at home. I did that quite well for most devices.
with this
private void setShortcutIcon() {
if (ShortcutManagerCompat.isRequestPinShortcutSupported(this)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
final ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
final ShortcutInfo pinShortcutInfo = new ShortcutInfo.Builder(this, "334")
.setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher))
.setShortLabel(getString(R.string.app_name))
.setIntent(new Intent(this, SplashActivity.class).setAction(Intent.ACTION_VIEW).putExtra("duplicate", false))
.build();
shortcutManager.requestPinShortcut(pinShortcutInfo, null);
} else {
final Intent shortcutIntent = new Intent(getApplicationContext(), SplashActivity.class);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
final Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.mipmap.ic_launcher));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
addIntent.putExtra("duplicate", …Run Code Online (Sandbox Code Playgroud) android app-launcher android-appshortcut android-8.1-oreo android-9.0-pie