赞
踩
需要在启动页添加如下代码:比如SplashActivity
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- // 避免从桌面启动程序后,会重新实例化入口类的activity
- if (!this.isTaskRoot()) { // 当前类不是该Task的根部,那么之前启动
- Intent intent = getIntent();
- if (intent != null) {
- String action = intent.getAction();
- if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(action)) { // 当前类是从桌面启动的
- super.onCreate(savedInstanceState);
- finish(); // finish掉该类,直接打开该Task中现存的Activity
- return;
- }
- }
- }
- super.onCreate(savedInstanceState);
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。