// 实际开发中常用的方法
Intent intent = new Intent();
intent.setClass(MainActivity.this, LoginActivity.class);
startActivity(intent);
//<疯狂Android>中介绍的方法
ComponentName comp = new ComponentName(MainActivity.this, FullscreenActivity02.class);
Intent intent = new Intent();
intent.setComponent(comp);
startActivity(intent);
界面间传值:
// 数据打包
Bundle bdl = new Bundle();
bdl.putString("name", "A");
bdl.putInt("years", 17);
// 跳界传参
Intent itt_1 = new Intent(this, A01_Activity.class);
itt_1.putExtras(bdl); // 起跳
startActivity(itt_1);
//-----------------------------------------------------------------
// Intent->Bundle->取值
Intent itt_2 = getIntent();
Bundle dbl = itt_2.getExtras();
String str = dbl.getString("name");
int n = dbl.getInt("years"); System.out.println(str + "●<--------------------->●" + n);
或者不直接使用Bundle传参
// 跳界传参
Intent itt_1 = new Intent(this, A01_Activity.class);
itt_1.putExtra("name", "A");
itt_1.putExtra("years", 18); // 起跳
startActivity(itt_1);
//-------取值的地方是一样的-------------------------------------------------------------------
// Intent->Bundle->取值
Intent itt_2 = getIntent();
Bundle dbl = itt_2.getExtras();
String str = dbl.getString("name");
int n = dbl.getInt("years");