码迷,mamicode.com
首页 > 其他好文 > 详细

startActivityForResult

时间:2015-12-25 23:57:43      阅读:437      评论:0      收藏:0      [点我收藏+]

标签:startactivityforresult

 FirstActivity: 

 

  Intent intent = new Intent(FirstActivity.this, SecondActivity.class);

  startActivityForResult(intent, 1);



 

  @Override

  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

     switch (requestCode) {

      case 1:

        if (resultCode == RESULT_OK) {

        String returnedData = data.getStringExtra("data_return");

        Log.d("FirstActivity", returnedData);

        }

      break;

      default:

  }

 }


  SecondActivity:


  Intent intent = new Intent();

  intent.putExtra("data_return", "Hello FirstActivity");

  setResult(RESULT_OK, intent);

  finish();


startActivityForResult

标签:startactivityforresult

原文地址:http://session.blog.51cto.com/8308112/1728435

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!