![](/img/trans.png)
[英]How to detect android app shortcut is removed from the Home Screen by the user?
[英]Android: Remove app shortcut from home screen
我正在嘗試從主屏幕刪除應用程序快捷方式。 使用這兩個動作:
com.android.launcher.action.INSTALL_SHORTCUT
com.android.launcher.action.UNINSTALL_SHORTCUT
它對我來說非常完美,但是當我將圖標從應用列表中拖到主屏幕時, UNINSTALL_SHORTCUT
不起作用。 那么,這兩種方法之間的區別以及系統在每種情況下的行為方式有什么不同?
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);
}
嘗試這個。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.