比较简单,直接上代码:
//1.给intent维护图标和名称
Intent intent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,"ShortCut");
//2.点击快捷方式进入应用
Intent shortCutIntent = new Intent();
shortCutIntent.setAction("android.intent.action.splash");
shortCutIntent.addCategory("android.intent.category.DEFAULT");
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortCutIntent);
sendBroadcast(intent);
Toast.makeText(getApplicationContext(), "快捷方式已生成", 0).show();