标签:
1、Activity跳转
Intent intent = new Intent(MainActivity.this,NextActivity.class);
startActivity(intent);
跳转到NextActivity
2、带数据跳转
Intent intent = new Intent(MainActivity.this,NextActivity.class);
intent.putExtra("name","YinTing");
Bundle bundle = new Bundle();
bundle.putInt("age",22);
bundle.putChar("bood",‘b‘);
intent.putExtra("bundle",bundle);
startActivity(intent);
3、接收返回值跳转
Intent intent = new Intent(MainActivity.this,NextActivity.class);
intent.putExtra("name","YinTing");
Bundle bundle = new Bundle();
bundle.putInt("age",22);
bundle.putChar("bood",‘b‘);
intent.putExtra("bundle",bundle);
MainActivity.this.startActivityForResult(intent,1);
必须复写onActivityResult该方法。
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==1&&resultCode==1001){
String name= data.getStringExtra("name");
Toast.makeText(MainActivity.this,"---->"+name,Toast.LENGTH_LONG).show();
}
} NextActivity结束时带数据返回。
Intent intent=new Intent();
intent.putExtra("name","YangYi");
NextActivity.this.setResult(1001,intent);
NextActivity.this.finish();
4、Android生命周期
5、Activity现场保护
标签:
原文地址:http://www.cnblogs.com/swordyt/p/5479878.html