Skip to content Skip to sidebar Skip to footer

Startactivityforresult(...) Immediately Returns 0

When I call startActivityForResult(new Intent(getActivity(), VkAuth.class), VK_ID); on Samsung (on HTC and Nexus everything works fine), onActivityResult with requestCode == VK_ID

Solution 1:

after i removed android:launchMode="singleInstance", this misbehaivior stoped

Solution 2:

I had a similar behaviour on a Samsung Galaxy S4 running Android 4.4.2 API 17. I was starting an Activity with:

Intent intent = newIntent(this, MyActivity.class);
startActivityForResult(intent, CUSTOM_CODE);

However the onActivityResult got called immediately with resultCode=0 (ACTIVITY.RESULT_CANCELED). It was working perfectly fine on other devices.

Based on what @Yarh said, i looked in AndroidManifest and figured out that the Activity that executed the startActivityForResult has android:launchMode="singleInstance".

Removing this line definitely fixed the issue.

Solution 3:

You have not posted enough code for us to really see what is going on but I would check the following:

When you return from the activity you have just started up using startActivityForResult, please check whether you have setResult to RESULT_OK:

IntentreturnIntent=newIntent();
setResult(RESULT_OK, returnIntent);

Post a Comment for "Startactivityforresult(...) Immediately Returns 0"