安卓:从主屏幕删除应用程序快捷方式 [英] Android: Remove app shortcut from home screen

查看:191
本文介绍了安卓:从主屏幕删除应用程序快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从主屏幕删除应用程序快捷方式。使用这个两个动作:


  1. com.android.launcher.action.INSTALL_SHORTCUT

  2. com.android.launcher.action.UNINSTALL_SHORTCUT

它的工作非常适合我,但是当我拖动图标从应用列表主屏幕 UNINSTALL_SHORTCUT 不起作用。那么,有没有这两种方法以及系统的行为在每种情况下?

之间的差异
解决方案

 私人无效deleteShortCut(上下文的背景下){    意图shortcutIntent =新意图(Intent.ACTION_MAIN);
    shortcutIntent.setClassName(com.example.androidapp,SampleIntent);
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    shortcutIntent.putExtra(someParameter,的HelloWorld);    意图removeIntent =新的Intent();
    removeIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT,shortcutIntent);
    removeIntent.putExtra(Intent.EXTRA_SHORTCUT_NAMEShortcutName);
    removeIntent.putExtra(重复,FALSE);    removeIntent
            .setAction(com.android.launcher.action.UNINSTALL_SHORTCUT);
    context.sendBroadcast(removeIntent);
}

试试这个。

I'm trying to remove app shortcut from home screen. Using this two actions:

  1. com.android.launcher.action.INSTALL_SHORTCUT
  2. com.android.launcher.action.UNINSTALL_SHORTCUT

It works perfect for me, but when I drag icon from apps list to home screen UNINSTALL_SHORTCUT doesn't work. So, is there any difference between this two methods and how the system behave in each situation?

解决方案

private void deleteShortCut(Context context) {

    Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
    shortcutIntent.setClassName("com.example.androidapp", "SampleIntent");
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    shortcutIntent.putExtra("someParameter", "HelloWorld");

    Intent removeIntent = new Intent();
    removeIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    removeIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "ShortcutName");
    removeIntent.putExtra("duplicate", false);

    removeIntent
            .setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");       
    context.sendBroadcast(removeIntent);
}

Try this.

这篇关于安卓:从主屏幕删除应用程序快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆