1

I put finish() to backpressed method of my MainActivity but when i monitor cpu usage, I still see my app on the top of the list with cpu usage between %1 to %6.

I have no services running, I can't debug the currently open threads. So I don't know what's going on here.

Do you have any ideas? Whay can be the reason for an app keep using cpu even it was closed?

frankish
  • 6,738
  • 9
  • 49
  • 100
  • See: http://stackoverflow.com/questions/15544310/what-happens-when-all-activities-of-an-application-finishes – Morrison Chang Jul 05 '13 at 09:27
  • @MorrisonChang I can accept it to stay in the process list, but it uses cpu and I can't find why it uses it, I couldn't use Debug to see the active threads to identify what's going on... – frankish Jul 05 '13 at 10:04

1 Answers1

1

I put finish() to backpressed method of my MainActivity

Please simply remove your onBackPressed() handler, or use super.onBackPressed(). Do not override onBackPressed() to call finish().

when i monitor cpu usage, I still see my app on the top of the list with cpu usage between %1 to %6

You fail to indicate how you are monitoring CPU usage. Assuming that you are correct in your analysis, then you have leaked a thread that is doing work.

I can't debug the currently open threads

I have no idea what you mean by this statement. Use Traceview to monitor what code in your app is running.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    Thank you, eventhough I couldn't directly use traceview (Monitor app), I was able to find "Devices" window in Eclipse, which has some of the similar features of Monitor app. That way, I started profiling to record called methods and I was able to find called functions with this. Tough, if you have any other suggesstions I'll be looking forward to them. – frankish Jul 05 '13 at 10:52