Intent shortcutIntent = new Intent(getApplicationContext(), HomeScreen.class);
shortcutIntent.setAction(Intent.ACTION_MAIN);
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "AIMS ICD");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.aims));
addIntent.putExtra("duplicate", false);
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);
此代码工作正常,但在创建快捷方式后显示此消息“ Shortcut AIMS ICD created”,我不需要此消息
最佳答案
抱歉,无法阻止默认系统Toast出现(来源:Dianne, Google Employee)