Tuesday, December 18, 2012

Intent extra is stale after using android file selecor

In case you are using intents to communicate between activities, while using android file selection, you will have cases after the file selection which you get the old activity intent, which you already used after the file selection,
In this case, in the method:

 protected void onActivityResult(int requestCode, int resultCode, Intent intent)

That gets the file selection results and handle it,

call:
setIntent(intent);

to set the push the file selection intent to the top of the stack.
this way, the calling activity, onResume() method, will have the file selection intent, and not the previous intent (which is stale).