代码
<activity            android:name=".IconOne"            android:icon="@drawable/ic_launcher"            android:label="icon1"            android:launchMode="singleTask"            android:clearTaskOnLaunch="true"            android:screenOrientation="nosensor" >            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.DEFAULT" />                <category android:name="android.intent.category.LAUNCHER" />                <category android:name="android.intent.category.BROWSABLE" />            </intent-filter>        </activity>        <activity-alias            android:name="combine"            android:label="icon2"            android:targetActivity=".IconOne" >            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.DEFAULT" />                <category android:name="android.intent.category.LAUNCHER" />                <category android:name="android.intent.category.BROWSABLE" />            </intent-filter>        </activity-alias>


protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_icon_one);Log.d("debug", "onCreate" +  getIntent().getComponent().getClassName());}@Overrideprotected void onNewIntent(Intent intent) {// TODO Auto-generated method stubsuper.onNewIntent(intent);setIntent(intent);Log.d("debug", "onNewIntent" +  intent.getComponent().getClassName());}


这里使用activity-alias实现多个launch一起进入了IconOne.
需要注意的是:
1. IconOne中需要使用
android:launchMode="singleTask"
android:clearTaskOnLaunch="true"
否则, 下一次按Home退出后,按另一个icon进入就不会调用onNewIntent();
2. onNewIntent中注意setIntent否则getIntent()会是之前的intent.

更多相关文章

  1. radio button 旁边放图片以及强制程序本地化以及string含有参数
  2. Android——SQLite/数据库 相关知识总结贴
  3. android中searchable的使用
  4. Android日历控件
  5. Android(安卓)Studio中Gradle使用详解
  6. 用HTML5开发Android应用程序
  7. Android(安卓)之使用Android(安卓)Studio(AS)命令打release包
  8. [置顶] Android(安卓)使用Android(安卓)Studio + Gradle 或 命令
  9. Android(安卓)项目优化(七):阿里巴巴Android开发手册整理总结

随机推荐

  1. EditText 里的属性
  2. Android 5.0特性(SwipeRefreshLayout)
  3. 利用ContentProvider实现同步Binder
  4. android浏览器研究-下载
  5. Android(安卓)屏幕保护程序制作及源码
  6. Ubuntu 8.04下编译Android源码全过程
  7. Android Selector原理
  8. Android中的停止状态
  9. 百度地图SDK for Android v2.1.3全新发布
  10. android layout 按比例布局