当前位置: 代码迷 >> Android >> 2011.09.01(四)——— android 应用程序跳转到桌面
  详细解决方案

2011.09.01(四)——— android 应用程序跳转到桌面

热度:50   发布时间:2016-05-01 18:51:57.0
2011.09.01(4)——— android 应用程序跳转到桌面
2011.09.01(4)——— android 应用程序跳转到桌面

public boolean onKeyDown(int keyCode, KeyEvent event) {						if (keyCode == KeyEvent.KEYCODE_BACK) {            			Intent intent = new Intent(Intent.ACTION_MAIN);			intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);			intent.addCategory(Intent.CATEGORY_HOME); 			this.startActivity(intent);            			return true;		} else {			return super.onKeyDown(keyCode, event);		}			}



相当于 按下了home键
1 楼 lina3427 2011-11-24  
这个回到桌面,Launcher不会重新onCreate()吗?
2 楼 lipeng88213 2011-11-24  
lina3427 写道
这个回到桌面,Launcher不会重新onCreate()吗?

这个不清楚了  你测一下吧
3 楼 lina3427 2011-11-25  
lipeng88213 写道
lina3427 写道
这个回到桌面,Launcher不会重新onCreate()吗?

这个不清楚了  你测一下吧


哦,测了一下,不会哦,因为本来从Launcher进入应用程序的时候就不会Destroy

那那,再请教一个问题:用这种方式回桌面不能用那个intent.putExtra()传值吗?我写的好像传不了呢,,???
4 楼 lipeng88213 2011-11-28  
lina3427 写道
lipeng88213 写道
lina3427 写道
这个回到桌面,Launcher不会重新onCreate()吗?

这个不清楚了  你测一下吧


哦,测了一下,不会哦,因为本来从Launcher进入应用程序的时候就不会Destroy

那那,再请教一个问题:用这种方式回桌面不能用那个intent.putExtra()传值吗?我写的好像传不了呢,,???

假如说可以传值 那么也应该是键值对的键肯定是已经特定的吧
  相关解决方案