有关startActivityForResult()和onActivityResult()之疑惑?
有关startActivityForResult()和onActivityResult(),浏览了一些帖子,推荐下:
http://blog.csdn.net/IT___LaDeng/article/details/6822813
不过碰见了一个比较蛋疼的问题: 现在要求我的程序中activity A 接收 activity B的一些数据,A和B不在同一个程序中
代码
public void onClick(View v) { switch (v.getId()) { case R.id.button: Intent intent = new Intent(TestandroidActivity.this, androidActivity.class); startActivityForResult(intent, 1); break; default: break; } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); System.out.println("onActivityResult"); System.out.println("requestCode+++++ :" +requestCode); System.out.println("resultCode+++++ :" +resultCode ); switch (requestCode) { case 1: if (resultCode == 2) { String i = data.getStringExtra("name"); textView.setText(i); DataFile.data = i; } break; default: break; } }
04-11 08:03:24.090: W/ActivityManager(74): Activity is launching as a new task, so cancelling activity result.04-11 08:03:24.109: W/WindowManager(74): Failure taking screenshot for (120x180) to layer 2101004-11 08:03:24.140: I/System.out(906): onActivityResult04-11 08:03:24.140: I/System.out(906): requestCode :104-11 08:03:24.149: I/System.out(906): resultCode :0