Android 开发之系统应用Launcher详解,简单添加和删除快捷方式及常见问题
1.. Launcher是什么?
1.1 Launcher是系统启动后加载的第一个应用程序
1.2 Launcher是其他应用程序的入口
2.Launcher的构成:

3. 主体四大组件的区别:
ShortCut: 应用程序的快捷方式
Appwidget:桌面小部件,图形不规则
LiveFolder: 文件夹
以ContentProvider的形式展示应用中特定数据的集合
WallPaper: 壁纸
预览图如下:

4. 通过按钮添加或者删除应用程序的快捷方式Demo:
Intent.EXTRA_SHORTCUT_INTENT,
布局文件:
Main.xml
import android.app.Activity;import android.content.ComponentName;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class LancherDemoActivity extends Activity { private Button button1; private Button button2; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); button1 = (Button) findViewById(R.id.BT_InstallShortCurt); button2 = (Button) findViewById(R.id.BT_UnInstallShortCurt); button1.setOnClickListener(new OnClickListener() {public void onClick(View v) {addShortCurt2DeskTop();}/** * 添加桌面快捷方式*/private void addShortCurt2DeskTop() { Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); //快捷方式的名称 shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "TonyAutoShortCut"); shortcut.putExtra("duplicate", false); //不允许重复创建 shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,Intent.ShortcutIconResource.fromContext(LancherDemoActivity.this, R.drawable.beauty));shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(LancherDemoActivity.this,LancherDemoActivity.class).setAction("com.android.action.test"));//发送广播sendBroadcast(shortcut);}}); /*** 删除桌面快捷方式*/button2.setOnClickListener(new OnClickListener() { public void onClick(View v) { deleteShortCurt2DeskTop(); } private void deleteShortCurt2DeskTop() { Intent shortcut = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT"); //快捷方式的名称 shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "TonyAutoShortCut"); shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(LancherDemoActivity.this,LancherDemoActivity.class).setAction("com.android.action.test")); sendBroadcast(shortcut);}}); }}否则删除无法生效