如果启动器是单层启动器,则创建快捷方式将使用户感到困惑。如何避免呢?
Here is my code
public void addShortcutToHomeScreen(Context context)
{
if (ShortcutManagerCompat.isRequestPinShortcutSupported(context))
{
ShortcutInfoCompat shortcutInfo = new ShortcutInfoCompat.Builder(context, "#1")
.setIntent(new Intent(context, LauncherActivity.class).setAction(Intent.ACTION_MAIN)) // !!! intent's action must be set on oreo
.setShortLabel(getString(R.string.app_name))
.setIcon(IconCompat.createWithResource(context, R.drawable.logo2))
.build();
ShortcutManagerCompat.requestPinShortcut(context, shortcutInfo, null);
//Toast.makeText(LauncherActivity.this, "Creating Shortcut Oreo", Toast.LENGTH_SHORT).show();
}
else
{
// Shortcut is not supported by your launcher
}
}