On Mar 5, 11:11 am, Chronos <g358279012044...@gmail.com> wrote: > @Tseng: I can't find this method - are you talking about class > Activity ? Yes, the final() method is belongs to the activity class and you can override it and put your code there.
That's how i did it in my activity class: @Override public void finish() { if(bSuccessfullySaved) // Notify the caller Activity that the user successfully // edited or inserted the data set setResult(Activity.RESULT_OK); else // Notify the caller Activity that the user has canceled the activity // without altering anything setResult(Activity.RESULT_CANCELED); super.finish(); } It was necessary to do it this way. First I tried to do it in the button listeners (calling setResult before finish()), but i encountered one problem: If a user pressed the "back" button on their Android phone, it didn't worked, because he hasn't hit the button. The more i was thinking the more i noticed it would become really complicated (you'd had to catch all possibilities which could lead to a user to exit/finalize the activity and could lead to hardly maintainable/readable code (and easily cause errors/bugs when you forgot to catch all events) I then tried to send in onPause or onDestroyed (dunno anymore), but this didn't worked to (as Dianne explained it). While testing i realized that it could be set before the finish(); call. So i had the idea to override the final() method, because finish() is called everytime the activity is closed. This worked very well for me ad at the same time it catched all possibile ways on which the application could be closed. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---