Android 如何以编程方式在自定义启动器的主屏幕上添加消息应用程序图标?

Android 如何以编程方式在自定义启动器的主屏幕上添加消息应用程序图标?,android,Android,如何在自定义启动器的主屏幕上添加应用程序图标。在我的自定义启动器中,只有一个按钮显示用于在网格视图中打开所有应用程序窗口的按钮。但我想在主页上添加更多的应用程序图标 <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> Intent shortcutIntent = new Intent(); shortcutIntent.setClassName("package

如何在自定义启动器的主屏幕上添加应用程序图标。在我的自定义启动器中,只有一个按钮显示用于在网格视图中打开所有应用程序窗口的按钮。但我想在主页上添加更多的应用程序图标

<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
 Intent shortcutIntent = new Intent();
 shortcutIntent.setClassName("packageName", "className");
 Intent addIntent = new Intent();
 addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
 addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "shortcut_name");
 addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
 Intent.ShortcutIconResource.fromContext(context, R.drawable.icon));
 addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
 context.sendBroadcast(addIntent);