Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.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
Java 用户删除应用程序快捷方式时如何更改共享首选项_Java_Android - Fatal编程技术网

Java 用户删除应用程序快捷方式时如何更改共享首选项

Java 用户删除应用程序快捷方式时如何更改共享首选项,java,android,Java,Android,使用这个我正在创建应用程序快捷方式,但当用户将其从主屏幕中删除时,如何检查 Intent shortcutIntent = new Intent(context, Doctor.class); shortcutIntent.setAction(Intent.ACTION_MAIN); Intent addIntent = new Intent(); addIntent.putExtra(Constants.SEARCH_QUERY_HINT, getResources().getString(R

使用这个我正在创建应用程序快捷方式,但当用户将其从主屏幕中删除时,如何检查

Intent shortcutIntent = new Intent(context, Doctor.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
Intent addIntent = new Intent();
addIntent.putExtra(Constants.SEARCH_QUERY_HINT, getResources().getString(R.string.Search_By_name_speciality));
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Doctor");
addIntent.putExtra("duplicate", false);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.doctor));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
context.sendBroadcast(addIntent);

我想一个更好的问题是,为什么你需要知道用户已经删除了你的应用程序快捷方式?实际上,我正在共享首选项中保存值以避免重复快捷方式,因此当用户删除应用程序快捷方式时,我想更改首选项值。我想如果用户选择复制你的快捷方式,这将是用户的首选项。为什么这对你的应用程序很重要?你的偏好是什么意思?我想简而言之。。为什么您需要知道它已被删除?也许用一种无关紧要的方式来编写它——最终深入探讨为什么以及你问的问题是否首先是必要的。但我不想让用户创建重复的快捷方式如果你看到了什么应用程序“添加聊天快捷方式”,我希望与此相同。并且不会创建聊天快捷方式的副本