Using startActivityForResult, how to get requestCode in child activity?

You can pass request code by put extra. intent.putExtra(“requestCode”, requestCode); Or if you have used startActivityForResult many times, then better than editing each, you can override the startActivityForResult in your Activity, add you code there like this @Override public void startActivityForResult(Intent intent, int requestCode) { intent.putExtra(“requestCode”, requestCode); super.startActivityForResult(intent, requestCode); } So there is no need … Read more

How to manage startActivityForResult on Android

From your FirstActivity, call the SecondActivity using the startActivityForResult() method. For example: int LAUNCH_SECOND_ACTIVITY = 1 Intent i = new Intent(this, SecondActivity.class); startActivityForResult(i, LAUNCH_SECOND_ACTIVITY); In your SecondActivity, set the data which you want to return back to FirstActivity. If you don’t want to return back, don’t set any. For example: In SecondActivity if you want … Read more