Thanxx!
just done it with onPause and Resume and it works yipee!! Couldn't see
the wood for the trees after some hours of programming! Thanxx!

On 3 Jun., 14:43, Mark Murphy <[EMAIL PROTECTED]> wrote:
> cbraun75 wrote:
> > Just have a Problem withstoppingathreadby finishing a programm
> > through
> > - just go back to mainmenu or go back with the back button.
>
> > It is replying always on in the Log modul the data.
>
> > My programm catches the Location data from the GPS modul and should
> > send it to a webservice. But when the home button or the back button
> > is pressed the threads are always going on ... and telling thethread
> > that there is an interrupt for him doesn't make anything.
>
> > Has anybody an idea why it's always running?
>
> You have implemented onDestroy(). However, merely pressing the home or
> back will not necessarily destroy your activity, any more than pressing
> the Start menu button in Windows closes all running programs.
>
> If you want to make sure your activity closes down, give the user some
> means (e.g., option menu choice) to call finish() on the activity. That
> should cause your activity to go through onDestroy().
>
> If, instead, you want to just disable your polling while your activity
> is hidden and restart it when it is visible, you should start your
> polling in onResume() and stop your polling in onPause(). It may be that
> your backgroundthreadkeeps running, but that it doesn't actually check
> and log the position when the activity is not visible.
>
> You can read more about the activity lifecycle, and the
> onResume()/onPause() pair, at:
>
> http://code.google.com/android/reference/android/app/Activity.html#Ac...
>
> You could also peek at the Threads/Handler demo from my book's sample code.
>
> >        public void run() {
> >             while(!Thread.currentThread().isInterrupted()) {
> >                  Message m = new Message();
> >                  m.what = MyData.GUIUPDATEIDENTIFIER;
> >                  MyData.this.myViewUpdateHandler.sendMessage(m);
>
> >                  try {
> >                      Thread.sleep(10000);
> >                  }
> >                  catch (InterruptedException e) {
> >                      Thread.currentThread().interrupt();
> >                  }
> >             }
> >        }
>
> Why not just break out of your infinite loop on an InterruptedException?
> That will cause you to exit run() and will therefore cause thisthread
> to terminate.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> _The Busy Coder's Guide to Android Development_ -- Available Now!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to