I am new in android. I want to send an object(object of p class) to first activity via onActivityForResult(). I write this code but when i use putSerializable(), first activity not run and i remain in MainActivity class. Why? How can i solve this problem?
MainActivity:
class MainActivity implements Serializable{
PClass p;
...
Intent intent=new Intent();
if(resultCode){
if(json!=null){
Bundle b=new Bundle();
b.putSerializable("p", p);
b.putString("result", json);
intent.putExtras(b);
}
setResult(RESULT_OK, intent);
}
else
setResult(RESULT_CANCELED, intent);
MainActivity.this.finish();
}
FristClass:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1) {
if (resultCode == RESULT_OK) {
Bundle b=data.getExtras();
if(b!=null)
p=(P)b.getSerializable("p");
String result=b.getString("result");
}
}
when i comment this line (b.putSerializable("p", p);) my FirstActivity run but if this line not comment, first activity not run and reamin on mainActivity class :(