Check if app launcher has menu key/swipe up for app drawer OR apps on home by default

319 Views Asked by At

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", false);
                getApplicationContext().sendBroadcast(addIntent);
            }
        }
    }

Except for devices having installed apps on home by-default, so in this case there was installed app icon on home already and one more duplicate icon was getting created as shortcut, which is not the expected behaviour.

So I started looking for this differentiation.

I want to know if the current app launcher has dedicated menu button or swipe up behaviour(Nougat, Oreo & Pie) for app list or apps are shown on home by default.

For e.g. mostly stock android phones have the launcher with menu button to check app list.

with menu

And other ROM like MIUI has default launcher where apps get's placed on home by default.

enter image description here

any help/suggestion appreciated, Thanks in advance.

0

There are 0 best solutions below