Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在主android屏幕上添加应用程序图标(react native)?_Javascript_Android_React Native_Apk - Fatal编程技术网

Javascript 如何在主android屏幕上添加应用程序图标(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

在安卓系统上安装时,它不会在主屏幕上添加快捷方式,但应用程序通常会这样做。你现在只能在应用程序抽屉中找到它。如何在android主屏幕上添加应用程序图标?

有些黑客可能会奏效,但在android上没有直接的方法。。。。但是请随意使用android.intent.action.CREATE\u shortcut请解释一下这个答案:)。只有代码的答案大多没有多大价值。谢谢你!继续努力!我需要在哪里添加此代码?(我不懂java,我正在使用react native)
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);
}