OnActivityResult not working (Android)
You have to destroy the second activity. Try pressing back button. I am able to see all the log messages in onActivityResult
First Activity
public class FirstActivity extends Activity {
/** Called when the activity is first created. */
int result = 100;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent i = new Intent(this,SecondActivity.class);
startActivityForResult(i, result);
}
@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
Log.i("H", "RequestCode:" + requestCode);
Log.i("H", "ResultCode:" + resultCode );
}
}
SecondActivity
public class SecondActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setResult(RESULT_OK);
Log.i("S","Exiting Second Activity");
}
}
in Source Class:
int activity=1;
Intent i=new Intent(Sourceclass.this,destination.class);
startActivityForResult(i,activity);
In Destination class:
Intent i=new Intent();
setResult(RESULT_OK,i);
finish();
In OnActivityResult of Source Class:
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == RESULT_OK)
{
if(requestCode==1)
{
Log.e("check","check");
}
}
}