google play 会自动在主屏幕上创建我们应用程序的快捷方式吗?

does google play automatically creates shortcut of our app on home screen?

我将在一周内启动我的第一个应用程序,想知道 google play 是否会自动将快捷方式添加到主屏幕,或者是否与代码有关。我有类似 this 的问题,但没有关于在安装时创建快捷方式的问题。

将此权限放入清单中

<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>

下面用于在 android 主屏幕

上创建快捷方式图标
private void ShortcutIcon(){

Intent shortcutIntent = new Intent(getApplicationContext(), MainActivity.class);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Test");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.ic_launcher));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);}

我遇到了这个问题,希望对您有所帮助。 http://viralpatel.net/blogs/android-install-uninstall-shortcut-example/

我启动了我的应用程序,发现 Google Play 会自动在主屏幕上创建一个快捷方式,我们不必在代码中这样做,尽管我不知道它是否以同样的方式工作在亚马逊应用商店。希望这对试图找到同一问题答案的人有所帮助。

Mohit Madaan 的回答是正确的。只是不要忘记将 duplicate 设置为 false 否则你可能有几个快捷方式:

addIntent.putExtra("duplicate", false);