Skip to content Skip to sidebar Skip to footer

Onactivityresult Of An Activity Not Called After Startactivityforresult Of Fragment

I have two activities ActivityOne and ActivityTwo each one contains one Fragment i did startActivityForResult(mIntent, Request_code) from the fragment of the first activity (Activ

Solution 1:

As mentioned in the comment, onActivityResult will only be called in the activity (e.g. ActivityOne) that started some other activity (e.g. ActivityTwo) for a result, using startActivityForResult(...);

You can read up on this in the developer guide here

If, by any chance, you are trying to pass something from ActivityOne to ActivityTwo, you can use putExtra(...) in ActivityOne & use getExtra(...) in ActivityTwo.

Solution 2:

You have to call onActivityResult method of the fragment of first activity inside onActivityResult method of first Activity. In other words you have to delegate onActivityResult method form activity to fragment. onActivityResult of your second activity will be called only if you call startActivityResult from within your second activity.

Solution 3:

onActivityResult of your second activity will be called if u call startActivityResult from within your second activity.In your case the onActivityResult of the first activity will be called

Solution 4:

ActivityOne onActivityResult will call onCreate of ActivityTwo.

In ActivityTwo, when you call setResult(requestNo,returnIntent), this will call the onActivityResult of ActivityOne.

Post a Comment for "Onactivityresult Of An Activity Not Called After Startactivityforresult Of Fragment"