Thank in advance for the time you pass on my problem.
I have 2 Activities :
Activity A and Activity B.
The Activity A call Activity B.
The Activity B is an activity for Sliding Tab (5 fragments are on the Sliding Tab module).
On one of the fragment, i use startActivityForResult()
intent = new Intent(this.getActivity(), Research.class);
intent.putExtra("Type", temp_type);
intent.putExtra("bundle", bundleapp);
intent.putExtra("position", position);
getActivity().startActivityForResult(intent,REQUEST_CODE);
I also tried :
intent = new Intent(this.getActivity(), Research.class);
intent.putExtra("Type", temp_type);
intent.putExtra("bundle", bundleapp);
intent.putExtra("position", position);
startActivityForResult(intent,REQUEST_CODE);
The first part work because i was redirected on the Research Activity.
On the Research Activity i call
compteur = 0;
Intent data = new Intent();
Bundle bundletest = new Bundle();
bundletest.putSerializable("Object", ObjectTest);
data.putExtras(bundletest);
Log.e("DEBUG", data.toString());
setResult(15, data);
super.finish();
It is here that i have a problem.
The method super.finish()
doesn't call onActivityResult() on Activity B
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
Log.e("DEBUG","ici");
super.onActivityResult(requestCode, resultCode, data);
String temp_path = "none";
String temp_name_file = "none";
if (resultCode != RESULT_CANCELED)
{
// Some code here
}
}
I have a also a method called onActivityResult on my Fragment but not called either.
Someone can help me ???
Sincerly,
Edit :
The problem :
I start The Activity B from The Activity A. In the Activity B i have a SlidingTabLayout (same as Google IO code 2014). On one of the 5 fragment i used i call startActivityForResult() ===> Activity C.
In Activity C ==> I call finish() or super.finish(). After that, i come back to Activity A ===> First misunderstanding. (Why Activity A) ===> Second, No Called OnActivityResult() done ....
Maybe my app Crash ??? But i don't see anything on the logcat
Thank Again
Calling startActivityForResult
will trigger onActivityResult
in the activity that started it, so in this case Activity A would receive the call to onActivityResult
. Additionally, when using startActivityForResult
, you should set a result code by calling setResult
before calling finish
, to help you distinguish between different result states (i.e. success vs failure).