1:建立表徵圖如下
Intent intent = new Intent();
intent.setClass(this, SplashActivity.class);
Intent addShortcut = new Intent(ACTION_ADD_SHORTCUT);
Parcelable icon = Intent.ShortcutIconResource.fromContext(this,
R.drawable.icon);
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
addShortcut.putExtra("duplicate", 0);
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
sendBroadcast(addShortcut);
2:刪除表徵圖如下:
Intent intent = new Intent();
intent.setClass(this, SplashActivity.class);
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
Intent addShortcut = new Intent(ACTION_ADD_SHORTCUT);
Parcelable icon = Intent.ShortcutIconResource.fromContext(this,
R.drawable.icon);
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
addShortcut.putExtra("duplicate", 0);
addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
sendBroadcast(addShortcut);
intent.setAction("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
需要兩個過濾屬性