Android快捷方式在VIVO 10中不起作用

Android快捷方式在VIVO 10中不起作用,android,keyboard-shortcuts,shortcut,android-shortcut,android-shortcutmanager,Android,Keyboard Shortcuts,Shortcut,Android Shortcut,Android Shortcutmanager,我在我的应用程序中实现了快捷方式,但这在维梧10(Funtouch OS)中不起作用。请帮帮我。我已经用了很多方法,但没有成功 方法1:我正在使用此代码,但不工作 @SuppressLint("NewApi") private fun shortcut(){ val shortcutManager = getSystemService(ShortcutManager::class.java) val nhentaiIntent = Intent(this, M

我在我的应用程序中实现了快捷方式,但这在维梧10(Funtouch OS)中不起作用。请帮帮我。我已经用了很多方法,但没有成功

方法1:我正在使用此代码,但不工作

@SuppressLint("NewApi")
private fun shortcut(){
    val shortcutManager = getSystemService(ShortcutManager::class.java)
    val nhentaiIntent = Intent(this, MainActivity::class.java)
    nhentaiIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
    nhentaiIntent.action = Intent.ACTION_VIEW
    if (shortcutManager!!.isRequestPinShortcutSupported) {
        val pinShortcutInfo = ShortcutInfo.Builder(this, "my-shortcut")
                .setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher))
                 .setShortLabel("hello Shortcut")
                .setIntent(nhentaiIntent)
                .build()
        val pinnedShortcutCallbackIntent = shortcutManager.createShortcutResultIntent(pinShortcutInfo)
        val successCallback = PendingIntent.getBroadcast(this, /* request code */ 0, pinnedShortcutCallbackIntent, /* flags */ 0)

        shortcutManager.requestPinShortcut(pinShortcutInfo, successCallback.intentSender)
    }

}
Intent nhentaiIntent = new Intent(context, MainActivity.class);
    nhentaiIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    nhentaiIntent.setAction(Intent.ACTION_VIEW);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
        if (shortcutManager.isRequestPinShortcutSupported()) {
            ShortcutInfo info = new ShortcutInfo.Builder(context, "Shortcut")
                    .setIntent(nhentaiIntent)
                    .setIcon(Icon.createWithResource(context, R.mipmap.ic_launcher))
                    .setShortLabel("Hello ")
                    .setLongLabel("Lable")
                    .build();
            Intent addIntent = shortcutManager.createShortcutResultIntent(info);
            shortcutManager.requestPinShortcut(info, PendingIntent.getBroadcast(context, 0, addIntent, 0).getIntentSender());
            Toast.makeText(context, "supported_launcher", Toast.LENGTH_LONG).show();
        } else {
            // TODO: Maybe implement this for launchers without pin shortcut support?
            // TODO: Should be the same with the fallback for Android < O
            // for now just show unsupported
            Toast.makeText(context, "unsupported_launcher", Toast.LENGTH_LONG).show();
        }
    }
private fun addShourcut() {
    if (ShortcutManagerCompat.isRequestPinShortcutSupported(applicationContext)) {
        val shortcutInfo =
            ShortcutInfoCompat.Builder(applicationContext, "#1")
                .setIntent(
                    Intent(applicationContext, MainActivity::class.java).setAction(
                        Intent.ACTION_MAIN
                    )
                ) // !!! intent's action must be set on oreo
                .setShortLabel("Test")
                .setIcon(
                    IconCompat.createWithResource(
                        applicationContext,
                        R.mipmap.ic_launcher
                    )
                )
                .build()
        ShortcutManagerCompat.requestPinShortcut(applicationContext, shortcutInfo, null)
    } else {
        Toast.makeText(
            this@MainActivity, "launcher does not support short cut icon",Toast.LENGTH_LONG).show()
    }
}
方法2:我也使用此代码,但不工作

@SuppressLint("NewApi")
private fun shortcut(){
    val shortcutManager = getSystemService(ShortcutManager::class.java)
    val nhentaiIntent = Intent(this, MainActivity::class.java)
    nhentaiIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
    nhentaiIntent.action = Intent.ACTION_VIEW
    if (shortcutManager!!.isRequestPinShortcutSupported) {
        val pinShortcutInfo = ShortcutInfo.Builder(this, "my-shortcut")
                .setIcon(Icon.createWithResource(this, R.mipmap.ic_launcher))
                 .setShortLabel("hello Shortcut")
                .setIntent(nhentaiIntent)
                .build()
        val pinnedShortcutCallbackIntent = shortcutManager.createShortcutResultIntent(pinShortcutInfo)
        val successCallback = PendingIntent.getBroadcast(this, /* request code */ 0, pinnedShortcutCallbackIntent, /* flags */ 0)

        shortcutManager.requestPinShortcut(pinShortcutInfo, successCallback.intentSender)
    }

}
Intent nhentaiIntent = new Intent(context, MainActivity.class);
    nhentaiIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    nhentaiIntent.setAction(Intent.ACTION_VIEW);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
        if (shortcutManager.isRequestPinShortcutSupported()) {
            ShortcutInfo info = new ShortcutInfo.Builder(context, "Shortcut")
                    .setIntent(nhentaiIntent)
                    .setIcon(Icon.createWithResource(context, R.mipmap.ic_launcher))
                    .setShortLabel("Hello ")
                    .setLongLabel("Lable")
                    .build();
            Intent addIntent = shortcutManager.createShortcutResultIntent(info);
            shortcutManager.requestPinShortcut(info, PendingIntent.getBroadcast(context, 0, addIntent, 0).getIntentSender());
            Toast.makeText(context, "supported_launcher", Toast.LENGTH_LONG).show();
        } else {
            // TODO: Maybe implement this for launchers without pin shortcut support?
            // TODO: Should be the same with the fallback for Android < O
            // for now just show unsupported
            Toast.makeText(context, "unsupported_launcher", Toast.LENGTH_LONG).show();
        }
    }
private fun addShourcut() {
    if (ShortcutManagerCompat.isRequestPinShortcutSupported(applicationContext)) {
        val shortcutInfo =
            ShortcutInfoCompat.Builder(applicationContext, "#1")
                .setIntent(
                    Intent(applicationContext, MainActivity::class.java).setAction(
                        Intent.ACTION_MAIN
                    )
                ) // !!! intent's action must be set on oreo
                .setShortLabel("Test")
                .setIcon(
                    IconCompat.createWithResource(
                        applicationContext,
                        R.mipmap.ic_launcher
                    )
                )
                .build()
        ShortcutManagerCompat.requestPinShortcut(applicationContext, shortcutInfo, null)
    } else {
        Toast.makeText(
            this@MainActivity, "launcher does not support short cut icon",Toast.LENGTH_LONG).show()
    }
}
请帮助我的任何人,我花了更多的时间在这个问题上