android系统的homescreen 就是一个系统的launcher,由它来负责启动其他的Activity。
系统launcher的Activity

 
  
  1. <activity 
  2.     android:name="com.android.launcher2.Launcher" 
  3.     android:launchMode="singleTask" 
  4.     android:clearTaskOnLaunch="true" 
  5.     android:stateNotNeeded="true" 
  6.     android:theme="@style/Theme" 
  7.     android:screenOrientation="nosensor" 
  8.     android:windowSoftInputMode="stateUnspecified|adjustPan"> 
  9.     <intent-filter> 
  10.         <action android:name="android.intent.action.MAIN" /> 
  11. <!--设置主屏-->
  12.         <category android:name="android.intent.category.HOME" />  
  13.         <category android:name="android.intent.category.DEFAULT" /> 
  14.         <category android:name="android.intent.category.MONKEY"/> 
  15.     </intent-filter> 
  16. </activity> 


首先launcher使用pickShortcut()方法调用pickActivity对象,pickActivity对象调用check Intent filter() and chose item(),返回一个Intent对象。如图
    


选中图标之后,会在HomeScreen上添加一个图标。

2.怎样创建android桌面图标,代码如下
    在androd manifest.xml的Activity标签中添加创建图标的动作

 
  
  1. <action android:name="android.intent.action.CREATE_SHORTCUT"/> 
    然后在Activity中创建一个Intent对象
 
  
  1.   Intent addShortcut; 
  2. if(getIntent().getAction().equals(Intent.ACTION_CREATE_SHORTCUT)) 
  3.     addShortcut = new Intent(); 
  4.     addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "快捷方式"); 
  5.     addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher)); 
  6.     addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(LauncherSimpleActivity.this,MainActivity.class)); //点击图标启动的Activity 
  7.     setResult(RESULT_OK, addShortcut); 
  8. }else { 
  9.     setResult(RESULT_CANCELED); 
  10. finish(); //添加完成之后销毁这个Activity