I've been dealing with the same issues and i tried all these. And
nothing seems to work well.
First of all, having a thread that's part of your activity running
after your activity's onDestroy has been called is tricky. It can lead
to memory-leaks, etc.

I finally decided to create a Service for these kinds of tasks and it
simplified everything. It's an initial expense writing a Service, but
it pays off in your activity's code and its life-cycle handling.

Your activity binds to the service on the onCreate and unbinds it on
the onDestroy (or, even better, on onResume and onPause).
To prevent the Service from shutting down, call startService from your
activity as well, just after binding to it. When your activity
unbinds, the service won't be shut down and your service's threads can
keep running safely. When your activity is recreated, just re-bind to
the service, have your activity query the service for the most current
state of your Service's threads and voila!

Your Activity:
  Register a callback service. The service can call your activity back
with important updates:
    Handle callbacks from service.

  onCreate:
     bind to service.
     start-service as well. This will keep the service alive when
unbinding from it.
     request callback from service giving the latest state/info of the
service's threads/process.

  onDestroy:
     unbind from service.

On Mar 11, 10:18 am, Stoyan Damov <stoyan.da...@gmail.com> wrote:
> unless he traps the back button in onKeyDown
>
>
>
> On Wed, Mar 11, 2009 at 2:51 PM, Marco Nelissen <marc...@android.com> wrote:
>
> > That will solve the problem when opening/closing the keyboard, but
> > won't solve it when e.g. starting the app and then immediately hitting
> > the back button to exit it.
>
> > On Wed, Mar 11, 2009 at 5:37 AM, Stoyan Damov <stoyan.da...@gmail.com> 
> > wrote:
>
> >> keyboardHidden|orientation
>
> >> On Wed, Mar 11, 2009 at 2:34 PM, mobilekid <mobilek...@googlemail.com> 
> >> wrote:
>
> >>> For some reason that seems not to work in my case. I've declared the
> >>> activity as android:configChanges="orientation" in the
> >>> AndroidManifest.xml, which I assume will call onConfigurationChanged
> >>> (Configuration). So for testing purposes I've simply implemented it as
> >>> follows:
>
> >>> @Override
> >>> public void onConfigurationChanged (Configuration newConfig){
> >>>        Log.i(this.toString(), "I've been called!");
> >>>        super.onConfigurationChanged(newConfig);
> >>> }
>
> >>> However, it never gets called. Am I doing anything wrong here?!
> >>> Thanks!
>
> >>> On Mar 11, 11:44 am, Stoyan Damov <stoyan.da...@gmail.com> wrote:
> >>>> Yes, basically if you declare your activity's orientation to be
> >>>> "sensor" there's nothing else to do (I think).- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to