Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7561739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:14:04+00:00 2026-05-30T13:14:04+00:00

I just got started today developing for Android. I tried to make an application

  • 0

I just got started today developing for Android. I tried to make an application that uses a SurfaceView to draw some simple shapes, but couldn’t get it working based on menu events (the surface was always invalid), so I decided to implement threads. Now the problem is I can’t figure out how to stop a stray thread from running. I started the application in debug mode, then selected the menu item that starts the thread. Then I hit the back button on the emulator’s interface to get out of the application. But my breakpoints on the thread continued to be hit. So I went back into the application by clicking on it in the application list in the emulator, and selected the command to stop the thread. But it did not detect that the thread was running — like it was a different application instance.

There are many subtle questions underneath my main question which is “How should I handle the shut-down of threads in an android application most reliably?”

  1. Can I access the original instance?
  2. Should I have gotten the original instance when I went back in?
  3. Does selecting it from the application menu instead of starting the debugger affect the original instance visibility?
  4. Can/should I terminate the activity/application?
  5. Can the debugger (Eclipse) force it to stop somehow without resetting the whole device?
  6. Does a SurfaceView need threads in order to function rather than trying to lock the context during a menu event?

I looked at Close application and launch home screen on Android but it suggests that applications should not be terminated, so I’m not sure what to do.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:14:05+00:00Added an answer on May 30, 2026 at 1:14 pm

    It sounds like you’re trying to use threads in a strange way. In Android, if you’re working with the UI, you shouldn’t be using vanilla java threads. Instead, you should be using an AsyncTask. If you try to access the UI from a non-UI thread, the Android runtime will complain at you. Instead, you need to pass messages back and forth between your processing threads and your Activities (where you actually manage the UI). This is done with the use of Messengers and Handlers, but the process gets complicated. Instead, a much better solution is to use the AsyncTask model, which will allow you to perform actions in the background which seamlessly update the UI. This is very typically used in things like networking applications, where you download some information in a task, and then update your UI accordingly. So go try reading through a few AsyncTask tutorials and find out all the cool things it can do for you (the hell of dealing with threading headaches in Android is mostly avoided by using this model, and in reality you should never have to fight to kill off a thread).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just got started with Mono Develop and Im trying to make a simple
I just started c++ today. I am doing some simple registration program. I want
I just started reading Effective C++ today and got to the point where the
I just got Delphi 2009 and have previously read some articles about modifications that
I just got started with Android and I was wondering how to use listeners
I have a java application for an ATC. I just got started with the
I just got started with Scala/LiftWeb/Sbt developing, and I'd like to import a Sbt
I just got started running UI tests against my ASP.NET MVC application using WatiN.
Just got started with Android programming and i got a task where im supposed
I've just started using VS2010. I've got a largish solution that migrated successfully from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.