我创建我的应用程序的主屏幕上创建快捷方式时,应用程序启动,它是在所有设备多个主屏幕快捷方式在Nexus 7上标签
但是,的Nexus标签就可以对每一个应用程序启动创建多个快捷方式工作正常?
如何在创建应用程序时将快捷方式创建一次,并在应用程序上卸载该应用程序?
private void AddShortcutIconToHomeScreen() {
Intent shortcutIntent = new Intent(this, EmployeeListActivity.class);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Device Tracker");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(getApplicationContext(),
R.drawable.ic_launcher));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
addIntent.putExtra("duplicate", false);
getApplicationContext().sendBroadcast(addIntent);
}
谢谢Mehul。基本上,它会创建或删除应用程序第一次拉扯时的快捷方式。如何在App安装或删除时调用此方法? –
使用removeShortcut()方法我也可以在Nexus 7选项卡上看到多个图标,它可以在所有其他设备上使用removeShortcut()方法完美实现 –
如果您只想为首次启动应用程序执行某些操作,那么您需要为了保持'SharedPreference'中的轨道,所以它不会在下次启动时执行相同的操作。并且关于卸载的确认,android没有这样的功能。 –