Android之生成快捷方式

  1. //1.给intent维护图标和名称
  2. Intent intent = new Intent( "com.android.launcher.action.INSTALL_SHORTCUT");
  3. intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
  4. intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "ShortCut");
  5. //2.点击快捷方式进入应用
  6. Intent shortCutIntent = new Intent();
  7. shortCutIntent.setAction( "android.intent.action.splash");
  8. shortCutIntent.addCategory( "android.intent.category.DEFAULT");
  9. intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortCutIntent);
  10. sendBroadcast(intent);
  11. Toast.makeText(getApplicationContext(), "快捷方式已生成", 0).show();

猜你喜欢

转载自blog.csdn.net/feelinghappy/article/details/80901661