onActivityResult not call in the Fragment

The reason why this doesn’t work is because you are calling startActivityForResult() from within a nested fragment. Android is smart enough to route the result back to an Activity and even a Fragment, but not to a nested Fragment hence why you don’t get the callback. (more information to why that doesn’t work here or … Read more

zxing onActivityResult not called in Fragment only in Activity

As Martynnw pointed out the issue is to call fragment.startActivityForResult instead of activity.startActivityForResult. So just use next wrapper: import android.content.Intent; import android.support.v4.app.Fragment; import com.google.zxing.integration.android.IntentIntegrator; public final class FragmentIntentIntegrator extends IntentIntegrator { private final Fragment fragment; public FragmentIntentIntegrator(Fragment fragment) { super(fragment.getActivity()); this.fragment = fragment; } @Override protected void startActivityForResult(Intent intent, int code) { fragment.startActivityForResult(intent, code); } … Read more

How to use onActivityResult method from other than Activity class

You need an Activity on order to receive the result. If its just for organisation of code then call other class from Activty class. public class Result { public static void activityResult(int requestCode, int resultCode, Intent data){ … } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Result.activityResult(requestCode,resultCode,data); … }

Android: how to make an activity return results to the activity which calls it?

In order to start an activity which should return result to the calling activity, you should do something like below. You should pass the requestcode as shown below in order to identify that you got the result from the activity you started. startActivityForResult(new Intent(“YourFullyQualifiedClassName”),requestCode); In the activity you can make use of setData() to return … Read more

OnActivityResult method is deprecated, what is the alternative?

A basic training is available at developer.android.com. Here is an example on how to convert the existing code with the new one: The old way: public void openSomeActivityForResult() { Intent intent = new Intent(this, SomeActivity.class); startActivityForResult(intent, 123); } @Override protected void onActivityResult (int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK && requestCode … Read more