Javascript 如何在主android屏幕上添加应用程序图标(react native)?
在安卓系统上安装时,它不会在主屏幕上添加快捷方式,但应用程序通常会这样做。你现在只能在应用程序抽屉中找到它。如何在android主屏幕上添加应用程序图标?有些黑客可能会奏效,但在android上没有直接的方法。。。。但是请随意使用android.intent.action.CREATE\u shortcut请解释一下这个答案:)。只有代码的答案大多没有多大价值。谢谢你!继续努力!我需要在哪里添加此代码?(我不懂java,我正在使用react native)Javascript 如何在主android屏幕上添加应用程序图标(react native)?,javascript,android,react-native,apk,Javascript,Android,React Native,Apk,在安卓系统上安装时,它不会在主屏幕上添加快捷方式,但应用程序通常会这样做。你现在只能在应用程序抽屉中找到它。如何在android主屏幕上添加应用程序图标?有些黑客可能会奏效,但在android上没有直接的方法。。。。但是请随意使用android.intent.action.CREATE\u shortcut请解释一下这个答案:)。只有代码的答案大多没有多大价值。谢谢你!继续努力!我需要在哪里添加此代码?(我不懂java,我正在使用react native) private void remove
private void removeShortcut () {
Intent shortcutIntent = new Intent(getApplicationContext(),
MainActivity.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
Intent addIntent = new Intent();
addIntent
.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "HelloWorldShortcut");
addIntent
.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);
}
private void addShortcut() {
Intent shortcutIntent = new Intent(getApplicationContext(), MainActivity.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "HelloWorldShortcut");
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);
}