Thanks for the idea - but this is not my problem: the result sent is the result I set in the onCreate method (a default result); if I fail to do this, I will get a java.lang.NullPointerException, which underlines my point - setResult() in onPause() is too late; my activity is not cancelled either - I always get an Activity.RESULT_OK.
Do you think, onPause() is the correct point to setResult() ? It seems to me, that the result has already been transmitted in some communication queue at this point - all calls to setResult() are in vain. On Mar 4, 12:39 pm, Stoyan Damov <stoyan.da...@gmail.com> wrote: > Actually read > carefullyhttp://developer.android.com/reference/android/app/Activity.html#star...) > > On Wed, Mar 4, 2009 at 1:31 PM, Stoyan Damov <stoyan.da...@gmail.com> wrote: > > Re: > > > - setResult() in client.onPause() is called TOO LATE; the result has > > already been transmitted to the parent (although the method > > client.onPause() seems to be called in time). > > > If the result has been already set, this means that the result value > > is CANCELLED immediately after your child activity started. > > Read carefully about the launchMode property - > >http://developer.android.com/guide/topics/manifest/activity-element.h... > > > Cheers > > > On Wed, Mar 4, 2009 at 12:59 PM,Chronos<g358279012044...@gmail.com> wrote: > > >> Hello there ;) > > >> I have some - maybe simple - problem; unfortunately I cannot find a > >> solution: > > >> I have two activities which communicate via: startActivityForResult(), > >> setResult(), onActivityResult. I will call the first activity "parent" > >> and the second one "client", although this may not be technically > >> correct; so the order of calls must be: > > >> parent.startActivityForResult() > >> client.setResult() > >> parent.onActivityResult() > > >> Now, where should I call setResult in the client activity ? > > >> I have already tried various possibilities which have all failed: > > >> - setResult() in client.onPause() is called TOO LATE; the result has > >> already been transmitted to the parent (although the method > >> client.onPause() seems to be called in time). > >> - client.onSaveInstanceState() is not guaranteed to be called at all > >> (and the documentation hints at the same timing problem). > >> - The only TECHNICALLY POSSIBLE solution seems to implement a change- > >> listener for any screen element and set the result there. This may > >> work in theory, but is NOT VIABLE in practice: (1) it is strenuous and > >> error-prone for activities with many elements; (2) it gets even more > >> complicated, when side-effects kick in (change one field in dependency > >> to another); (3) it is really slow, since one must write ALL contents > >> any time, a SINGLE element changes (and the generic Intent > >> communication is already slow by design). > > >> To me, it would seem most natural to overload the onPause() method and > >> setResult() there - once and for all. There MUST be some easier way > >> than implementing zounds of listeners ... > > >> Am I overlooking something ? Another listener I haven't stumbled over > >> yet ? Please prove me wrong ;) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---