0

I have to restart my application at an interval such as 1 hour. But when i try the code below, a new ctivity is starting but the activity which i want to close is still running on background as a thread :S

What do i have to do? Thanks..

if (timeOutOK) {

            finish();
            Intent i = getBaseContext().getPackageManager()
                    .getLaunchIntentForPackage(
                            getBaseContext().getPackageName());
            i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(i);

        }
GK Soft
  • 103
  • 2
  • 12
  • An activity cannot run in the background as another thread. Maybe if you outline what you're trying to achieve, someone here can help you out a little bit better. – Archit Nov 28 '12 at 16:09
  • nope! i have tried to close the main activity but it is still running on background and i can see in running applications. – GK Soft Dec 08 '12 at 09:43
  • i have written an application running on Samsung Tab, and we are riding this on a forklift :) It is gathering data from the wireless and sometimes device is out of the wireless area and can not reach my server to take data. Then sometimes it is crashing, no not crashing it is runnning but it doesnt take and show any informations that we have to send to monitor. – GK Soft Dec 08 '12 at 09:46

1 Answers1

0

You are probably keeping living references to the activity somewhere. Even after finish has been called, the old activity won't be GC-ed until there are no live references to it, so you need to update all references to point to the new Activity instead.

You saying it is running in the background as a thread doesn't make any sense, but your activity might keep performing operations on background threads - or on the UI thread - as long as it's not properly dealt with.

Tore Rudberg
  • 1,594
  • 15
  • 16