Saturday, April 2, 2011

onActivityResult not called in time

I wrote a small program that needed to use a preference screen. After the preferences were updated the application needs to update. To do that I used startActivityForResult to start the preferences screen, and onActivityResult to update the application.

Problem: onActivityResult wasn't called in time. Using Toast I've noticed it was called BEFORE the preferences screen opens.

Solution: In my case - the application was defined as launchMode=singleInstance, removing this put things back to place.

Note: This is true for Android 2.3.3. I didn't check the documentation to see if it's a normal behavior or an issue.

No comments: