Friday, August 12, 2011

[android-developers] Re: Activity Lifecycle question

Two questions: 1) why do you call super.onActivityResult()? The
ApiDemo examples do not. If you must call it, you should call if after
your own processing, since you want to catch the CANCELED first 2)
what code DO you have for handling other result codes? You should have
a default case at least so that you can put breakpoints there.

On Aug 12, 3:36 pm, "hectordu...@yahoo.com" <hectordu...@yahoo.com>
wrote:
> thank you guys for comments,
>
> i wonder if somebody has an idea to deal with this issue; i tried to
> catch the RESULT_CANCELED but nothing happens,
> the activity 1 is as follows:
>
>   public void onActivityResult(int requestCode, int resultCode, Intent
> rit) {
>       super.onActivityResult(requestCode, resultCode, rit);
>
>       if (resultCode == RESULT_OK) {
>                   yellowRoullete = (Roullete)
> rit.getParcelableExtra("updatedYellowRoullete");
>                   blueRoullete = (Roullete)
> rit.getParcelableExtra("updatedBlueRoullete");
>                   redRoullete = (Roullete)
> rit.getParcelableExtra("updatedRedRoullete");
>
>       }else if (resultCode == RESULT_CANCELED) {
>           redButton.setText("hDART CANCELLED ...");
>           Log.d("hDART", "CANCELLLED");
>
>       }else {
>           redButton.setText("INTERACTION ERROR ...");
>           Log.d("INTERACTION", "ERROR");
>
>       }//if
>       }
>
> after the user press back (in activity 2), application goes back to
> activity 1 but result is lost ... same an ESC :-(
>
> ... yes, onResume() is also too late ...
>
> thanks for help...
>
> On Aug 12, 2:21 pm, Mark Murphy <mmur...@commonsware.com> wrote:
>
> > On Fri, Aug 12, 2011 at 3:17 PM, Kostya Vasilyev <kmans...@gmail.com> wrote:
> > > Try calling setResult from onPause - I believe onStop is too late, due
> > > to how Start/Stop/Pause/Resume are intermingled.
>
> > Last I checked, even onPause() is too late.
>
> > Hector:
>
> > The idea is that you call setResult() when the user makes a choice
> > (e.g., from onListItemClick() of a ListActivity). The BACK button is
> > effectively like hitting <Esc> on a desktop dialog box, indicating
> > that you didn't really want to make that choice in the first place. As
> > TreKing notes in his reply he sent while I was typing this,
> > onActivityResult() is called with RESULT_CANCELED, so you can detect
> > this case.
>
> > Any activity started via startActivityForResult() must be designed to
> > allow users to say "sorry, never mind". In fact, pretty much
> > everything in Android needs to support "sorry, never mind".
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> > Android Training...At Your Office:http://commonsware.com/training

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment