标签:
Activity的跳转有两种方式:
Intent intent = new Intent(MainActivity.this, SecondActivty.class); startActivity(intent);
public static final int REQUEST_SEC = 1; //请求的ID Intent backIntent = new Intent(MainActivity.this, SecondActivty.class); startActivityForResult(backIntent, REQUEST_SEC);
Intent intent = new Intent(); intent.putExtra("value", "hello word"); intent.putExtra("input", MainActivity.REQUEST_SEC); setResult(RESULT_BACK,intent); finish();//返回前调用finish,销毁本activity,类似于back
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); Log.i(TAG_ACTIVITY, "requestCode:" + requestCode); Log.i(TAG_ACTIVITY, "resultCode:" + resultCode); if(resultCode == SecondActivty.RESULT_BACK && REQUEST_SEC == requestCode){ Toast.makeText(getApplicationContext(), data.getStringExtra("value"), Toast.LENGTH_SHORT).show(); } }
标签:
原文地址:http://www.cnblogs.com/Fredric-2013/p/4214545.html