intent用法:
MainActivity中
Intent intent=new Intent(MainActivity.this,NextActivity.class);
intent.putExtra("name", "Tom");
intent.putExtra("age", 23);
//学习了Bundle的用法
Bundle bundle=new Bundle();
bundle.putString("code", "124");
intent.putExtra("bundle", bundle);
startActivity(intent);
NextActivity中:
Intent intent=getIntent();
String name=intent.getStringExtra("name");
Log.i(TAG, "--name->"+name);
int age=intent.getIntExtra("age", 0);
Log.i(TAG, "--age-"+age);
Bundle bundle=intent.getBundleExtra("bundle");
String code=bundle.getString("code");
Log.i(TAG,"--code-"+code);
另外配置log的方法:
private final String TAG="NextActivity";
在window--showview--other--LogCat,create filter中,filter name:"NextActivity",by Log Tag:"NextActivity",by Log Level:info