Vid*_*nes 7 icons android uninstall
我正在使用类似的代码片段,如下所示在主屏幕上添加应用程序快捷方式:
Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
shortcutIntent.setClassName(this, this.getClass().getName());
shortcutIntent.putExtra(EXTRA_KEY, "ApiDemos Provided This Shortcut");
// Then, set up the container intent (the response to the caller)
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.shortcut_name));
Parcelable iconResource = Intent.ShortcutIconResource.fromContext(
this, R.drawable.app_sample_code);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
// Now, return the result to the launcher
setResult(RESULT_OK, intent);
Run Code Online (Sandbox Code Playgroud)
创建快捷方式没有问题,但在卸载应用程序时,快捷方式仍保留在主屏幕上.卸载其他应用程序时,他们似乎也删除了相应的主屏幕快捷方式.这是我尝试使用"创建代码快捷方式图标"实现的目标
Stackoverflow上的任何Android专家是否都知道在卸载应用程序时从主屏幕删除应用程序快捷方式需要什么?
我发现了一些相关的线程,但它们没有为我提供解决方案,但请随时赶上:
我认为你可以尝试将此操作放在第二个意图中:“com.android.launcher.action.INSTALL_SHORTCUT”
这对我有用,启动器图标安装在主屏幕上,当我卸载应用程序时,该图标被删除。已经为此苦苦挣扎了一段时间。
Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
shortcutIntent.setClassName(this, this.getClass().getName());
Intent intent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
Parcelable iconResource = Intent.ShortcutIconResource.fromContext(
this, R.drawable.launcher_icon);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);
sendBroadcast(intent);
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助。
| 归档时间: |
|
| 查看次数: |
3693 次 |
| 最近记录: |