Re: [android-beginners] Re: Application still consumes battery even tough it is closed

2010-07-04 Thread Mark Murphy
On Sat, Jul 3, 2010 at 7:42 PM, Indicator Veritatis mej1...@yahoo.com wrote:
 That may be true, but if so, there is a serious problem with the
 online Android documentation. For as I have already shown, the
 documentation clearly states that there is a possible transition
 direct from the started state to the stopped state, one that does not
 call onPause() first.

That would occur in fairly rare cases, when something occurs on the
device after onStart() and before onResume(). Since those methods are
invoked in rapid succession, something else taking over the screen
(e.g., phone call comes in) during that window is rather unlikely.
Developers should not be worrying about that particular scenario very
much, if at all.

 So other than your own authority, on what grounds do you say that the
 docs are wrong?

The docs are not wrong. However, my previous post was covering the
99.999% case, not every possible scenario.

On Sat, Jul 3, 2010 at 7:50 PM, Indicator Veritatis mej1...@yahoo.com wrote:
 This is certainly wrong.

No, it is certainly correct.

 Pressing the Back key does NOT cause
 onDestroy() to be called.

Yes, it does.

 It causes onPause() to be called.

And onStop(), and onDestroy().

 I have run
 this in the emulator too many times myself to believe that it does.

I even had to run my own test, just to confirm I hadn't slid into some
parallel dimension, before writing my previous post. onDestroy() is
called after the BACK button is pressed, just like it is supposed to.
It has behaved this way for over two years.

If you are unable to replicate this, there is a problem in your
development environment.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Consulting: http://commonsware.com/consulting

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: Application still consumes battery even tough it is closed

2010-07-04 Thread Indicator Veritatis
Hi, Mark-

As I should have expected for someone who did write a good book on
Android, I see your knowledge of the Android life-cycle really is
better than mine. But I am seeing something else that vitiates this
superior knowledge, your habit of stating unconditionally, in a very
general form, things that are only sometimes true.

For that is what you have done in both issues: 1) the issue of whether
or not there is a direct transition to the stopped state and 2) the
issue of whether it is true that Back always caused onDestroy() to be
called.

In neither case is your sweeping generalization justifiable, in both
cases you are misleading readers rather than helping them. Do you
really want to encourage, for example, Android programmers to fail to
handle correctly the case where onStop() is called without a
preceding, corresponding call to onPause()? Such programming sounds
very careless to me.

Even if most of the time (even your 99.999% is an overstatement), the
programmer can ignore this scenario, he should be aware that it
exists, so then when he needs to take care of it, he knows that he
needs to do so.

Similarly with the second issue: even Google violates the rule [that
onBackPressed() should cause onDestroy() to be called] often enough
that your readers are going to be confused if they forget that some
apps really do override onBackPressed(), they don't all call
onDestroy().

Finally, yes the docs are wrong. I already showed how they contradict
each other. And others have found other similar contradictions in the
docs. Take a look at my previous posts on this and see for yourself: I
provided the direct quotations.

On Jul 4, 2:14 am, Mark Murphy mmur...@commonsware.com wrote:
 On Sat, Jul 3, 2010 at 7:42 PM, Indicator Veritatis mej1...@yahoo.com wrote:
  That may be true, but if so, there is a serious problem with the
  online Android documentation. For as I have already shown, the
  documentation clearly states that there is a possible transition
  direct from the started state to the stopped state, one that does not
  call onPause() first.

 That would occur in fairly rare cases, when something occurs on the
 device after onStart() and before onResume(). Since those methods are
 invoked in rapid succession, something else taking over the screen
 (e.g., phone call comes in) during that window is rather unlikely.
 Developers should not be worrying about that particular scenario very
 much, if at all.

  So other than your own authority, on what grounds do you say that the
  docs are wrong?

 The docs are not wrong. However, my previous post was covering the
 99.999% case, not every possible scenario.

 On Sat, Jul 3, 2010 at 7:50 PM, Indicator Veritatis mej1...@yahoo.com wrote:
  This is certainly wrong.

 No, it is certainly correct.

  Pressing the Back key does NOT cause
  onDestroy() to be called.

 Yes, it does.

  It causes onPause() to be called.

 And onStop(), and onDestroy().

  I have run
  this in the emulator too many times myself to believe that it does.

 I even had to run my own test, just to confirm I hadn't slid into some
 parallel dimension, before writing my previous post. onDestroy() is
 called after the BACK button is pressed, just like it is supposed to.
 It has behaved this way for over two years.

 If you are unable to replicate this, there is a problem in your
 development environment.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 Android Consulting:http://commonsware.com/consulting

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


Re: [android-beginners] Re: Application still consumes battery even tough it is closed

2010-07-04 Thread Mark Murphy
On Sun, Jul 4, 2010 at 7:21 PM, Indicator Veritatis mej1...@yahoo.com wrote:
 Do you
 really want to encourage, for example, Android programmers to fail to
 handle correctly the case where onStop() is called without a
 preceding, corresponding call to onPause()? Such programming sounds
 very careless to me.

Generally, I'd recommend the implementations be independent. Wherever
possible, onStop() should not care whether or not onPause() preceded
it, even though most of the time, it will. That's pretty basic state
machine design.

 Even if most of the time (even your 99.999% is an overstatement), the
 programmer can ignore this scenario, he should be aware that it
 exists, so then when he needs to take care of it, he knows that he
 needs to do so.

I'm not arguing that it'd be nice if the docs explained the
circumstances of all of these corner cases better.

 Similarly with the second issue: even Google violates the rule [that
 onBackPressed() should cause onDestroy() to be called] often enough
 that your readers are going to be confused if they forget that some
 apps really do override onBackPressed(), they don't all call
 onDestroy().

I am sincerely hoping that somebody who overrides onBackPressed() will
notice that their fingers typed those keystrokes and will therefore
consider that, gee, maybe onBackPressed() might have something to do
with what happens when BACK is pressed. I am not aware of any supplied
Activity implementation (e.g., ListActivity) that overrides
onBackPressed(), so such behavior will not be hidden too often.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Consulting: http://commonsware.com/consulting

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: Application still consumes battery even tough it is closed

2010-07-03 Thread Flamechamp
I can do it now!
I finally solve my problem :)
thx 4 the discussion ^^

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: Application still consumes battery even tough it is closed

2010-07-03 Thread Indicator Veritatis
This is certainly wrong. Pressing the Back key does NOT cause
onDestroy() to be called. It causes onPause() to be called. I have run
this in the emulator too many times myself to believe that it does.
The application goes into the background, but it remains in memory, on
the activity stack. Only much later, if at all, is onDestroy() called.
Since most applications do not provide an 'Exit' button/key, and many
users do not use a Task Killer, onDestroy() might not be called until
power-down (or the next configuration change).

On Jul 2, 12:55 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Fri, Jul 2, 2010 at 3:38 PM, david2 enki1...@gmail.com wrote:
  onPause() is called whenever the activity loses the foreground from an
  input standpoint.

  onStop() is also called, if the activity is no longer visible on the 
  screen.

  onDestroy() is also called, if the activity instance is going away for 
  good.

  Hence, BACK calls onPause(), onStop(), and onDestroy(). HOME calls
  onPause() and onStop().

  Not true. Back does not call onDestroy.

 Yes, it does.

  On destroy is called when the
  system decides the application is going away.

 Such as when the user presses the BACK button.

  This does not normally
  occur on a back button or home button.

 Yes, it does normally occur on a BACK button.

  Processes stay around until
  memory is needed elsewhere.

 Which has little to do with onDestroy() of individual components
 within that process.

  And even then, documentation states that
  onDestroy may never get called even when the application is killed.

 Correct.

  In general BACK doesn't do anything additional vs. HOME.

 Yes, it does. It causes the activity to be destroyed.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 Android Training...At Your Office:http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: Application still consumes battery even tough it is closed

2010-07-02 Thread Indicator Veritatis
But what about when the user presses the home key? According to the
docs, onPause() is called WHENEVER the application goes invisible, not
just on the Back key, not just when another application is launched.
So no, it is not just on the Back key.


On Jun 26, 9:13 am, mahesh askmah...@gmail.com wrote:
 And you have to unregister it in your OnPause() and onStop().

 Just as ref if you do not know this already -
 OnPause() is called when you quit the application via the back button
 or start another app.
 OnStop() is called when it is actually killed (via task manager)

 -
 maheshhttp://android.maheshdixit.com

 On Jun 25, 2:25 pm, Mark Murphy mmur...@commonsware.com wrote:

  On Fri, Jun 25, 2010 at 5:21 PM, Flamechamp flamechamp1...@yahoo.com 
  wrote:
   This may sound stupid, but I have a problem with my application.
   I made an application to check the accelerometer and orientation
   sensor.
   I tested it on my Nexus One and it works.
   The problem starts when I close it. (I pressed the - button in the
   phone) When I checked the Battery usage. That program I made is still
   there.

  You also need to be sure to unregister your sensor listeners. If you
  do not, your program will not truly end, and you will continue
  receiving sensor data.

  --
  Mark Murphy (a Commons 
  Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

  _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.6
  Available!



-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


Re: [android-beginners] Re: Application still consumes battery even tough it is closed

2010-07-02 Thread Mark Murphy
On Fri, Jul 2, 2010 at 2:32 PM, Indicator Veritatis mej1...@yahoo.com wrote:
 But what about when the user presses the home key? According to the
 docs, onPause() is called WHENEVER the application goes invisible, not
 just on the Back key, not just when another application is launched.
 So no, it is not just on the Back key.

onPause() is called whenever the activity loses the foreground from an
input standpoint.

onStop() is also called, if the activity is no longer visible on the screen.

onDestroy() is also called, if the activity instance is going away for good.

Hence, BACK calls onPause(), onStop(), and onDestroy(). HOME calls
onPause() and onStop().

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: Application still consumes battery even tough it is closed

2010-07-02 Thread david2
This is a great discussion.
This is probably the most important aspect of Android. It is critical
for all developers to properly understand activity lifecycle. From the
apps I've seen, most do not.
Google should also do a better job of clarifying and documenting this
lifecycle with additional examples and discussion.

On Jul 2, 2:35 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Fri, Jul 2, 2010 at 2:32 PM, Indicator Veritatis mej1...@yahoo.com wrote:
  But what about when the user presses the home key? According to the
  docs, onPause() is called WHENEVER the application goes invisible, not
  just on the Back key, not just when another application is launched.
  So no, it is not just on the Back key.

 onPause() is called whenever the activity loses the foreground from an
 input standpoint.

 onStop() is also called, if the activity is no longer visible on the screen.

 onDestroy() is also called, if the activity instance is going away for good.

 Hence, BACK calls onPause(), onStop(), and onDestroy(). HOME calls
 onPause() and onStop().

Not true. Back does not call onDestroy. On destroy is called when the
system decides the application is going away. This does not normally
occur on a back button or home button. Processes stay around until
memory is needed elsewhere. And even then, documentation states that
onDestroy may never get called even when the application is killed.

In general BACK doesn't do anything additional vs. HOME.

In general, I'd rely primarily on onPause since you're likely to get
this call. onStop may not even be called in extreme situations, but is
normally called.


 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 Android Training...At Your Office:http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: Application still consumes battery even tough it is closed

2010-07-01 Thread Indicator Veritatis
That is what the diagram says, yes. But the text of the table says
something different: it says onPause() is called when the system is
about to resume another activity. But it also says that onStop() may
be called when the activity is no longer visible to the user.

More importantly, it says that this may happen EITHER because another
activity is being resumed (in which case onPause() will be called) OR
because it (the current activity) is being destroyed.

The implication is that no, we cannot count on onPause() being called
before onStop() is called, even if this is by far the more common
case.

Similarly, the same table says elsewhere that the next state for
onStart() can be EITHER onResume() OR onStop(). Again, no stop at
onPause().

Finally, I should point out that in 
http://developer.android.com/guide/topics/fundamentals.html#actlife,
the doc we are all following to discuss this issue, it says explicitly
that this table offers MORE detail than the diagram (following table
describes each of these methods in more detail). That implies that
the diagram is incomplete, but the table is if not complete, at least
more complete.

In a formal spec, the distinction would probably have been 'normative'
versus 'reference'. But the Android online docs do not use this
terminology.


On Jun 26, 4:51 pm, RichardC richard.crit...@googlemail.com wrote:
 Why both onPause() and onStop()?  Looking at the application lifecycle
 diagram

 http://developer.android.com/images/activity_lifecycle.png

 it's not possible to get to onStop() without going through onPause().

 If however, you have found this not to be the case, I will have to
 change my programs and also deal with possible exceptions from
 resources being released twice.

 Do you have a simple test as I have never seen this (onPause being
 skipped) happen?

 /Richard

 On 26 June, 17:13, mahesh askmah...@gmail.com wrote:

  And you have to unregister it in your OnPause() and onStop().

  Just as ref if you do not know this already -
  OnPause() is called when you quit the application via the back button
  or start another app.
  OnStop() is called when it is actually killed (via task manager)

  -
  maheshhttp://android.maheshdixit.com

  On Jun 25, 2:25 pm, Mark Murphy mmur...@commonsware.com wrote:

   On Fri, Jun 25, 2010 at 5:21 PM, Flamechamp flamechamp1...@yahoo.com 
   wrote:
This may sound stupid, but I have a problem with my application.
I made an application to check the accelerometer and orientation
sensor.
I tested it on my Nexus One and it works.
The problem starts when I close it. (I pressed the - button in the
phone) When I checked the Battery usage. That program I made is still
there.

   You also need to be sure to unregister your sensor listeners. If you
   do not, your program will not truly end, and you will continue
   receiving sensor data.

   --
   Mark Murphy (a Commons 
   Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

   _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.6
   Available!



-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: Application still consumes battery even tough it is closed

2010-06-30 Thread Indicator Veritatis
That link is a good start, and required reading, but I see they have
still left in the vague and contradictory language concerning which
callback must come next.

I am referring to the wording in the state diagram and the table
concerning whether onStart() or onRestart() are next, and which
callback must follow these. The position in the table makes it look
like onRestart() can follow onCreate() preceding onRestart(). But in
fact, onRestart() can never follow onCreate() directly: it can only
follow onStop(), when the user starts it again (as explained elsewhere
at the same link).

The above could be dismissed as reading too much into proximity of two
items in the table. The same cannot be said for the following:
the flowchart-style diagram shows only one possible transition from
onStart(): the transition to onResume(). But the text in the table
says it can transition to onStop() also. Both cannot be right. So
which is correct? How is the Android beginner supposed to know?

On Jun 28, 5:18 pm, RichardC richard.crit...@googlemail.com wrote:
 http://developer.android.com/intl/fr/guide/topics/fundamentals.html#l...

 On Jun 28, 7:49 pm, Flamechamp flamechamp1...@yahoo.com wrote: ermm... can 
 someone show me or give me an URL that shows how to use
  the onDestroy, onPause or onStop??

  I am really beginner and didn't understand how systems in Android are
  running.

  I really appreciate the help

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: Application still consumes battery even tough it is closed

2010-06-28 Thread Flamechamp
ermm... can someone show me or give me an URL that shows how to use
the onDestroy, onPause or onStop??

I am really beginner and didn't understand how systems in Android are
running.

I really appreciate the help

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: Application still consumes battery even tough it is closed

2010-06-28 Thread mahesh
You are right. It should just be on onPause() and not needed on
OnStop(). My bad...


-
mahesh

On Jun 26, 4:51 pm, RichardC richard.crit...@googlemail.com wrote:
 Why both onPause() and onStop()?  Looking at theapplicationlifecycle
 diagram

 http://developer.android.com/images/activity_lifecycle.png

 it's not possible to get to onStop() without going through onPause().

 If however, you have found this not to be the case, I will have to
 change my programs and also deal with possible exceptions from
 resources being released twice.

 Do you have a simple test as I have never seen this (onPause being
 skipped) happen?

 /Richard

 On 26 June, 17:13, mahesh askmah...@gmail.com wrote:

  And you have to unregister it in your OnPause() and onStop().

  Just as ref if you do not know this already -
  OnPause() is called when you quit theapplicationvia the back button
  or start another app.
  OnStop() is called when it is actually killed (via task manager)

  -
  maheshhttp://android.maheshdixit.com

  On Jun 25, 2:25 pm, Mark Murphy mmur...@commonsware.com wrote:

   On Fri, Jun 25, 2010 at 5:21 PM, Flamechamp flamechamp1...@yahoo.com 
   wrote:
This may sound stupid, but I have a problem with myapplication.
I made anapplicationto check the accelerometer and orientation
sensor.
I tested it on my Nexus One and it works.
The problem starts when I close it. (I pressed the - button in the
phone) When I checked theBatteryusage. That program I made isstill
there.

   You also need to be sure to unregister your sensor listeners. If you
   do not, your program will not truly end, and you will continue
   receiving sensor data.

   --
   Mark Murphy (a Commons 
   Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

   _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.6
   Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: Application still consumes battery even tough it is closed

2010-06-28 Thread RichardC
http://developer.android.com/intl/fr/guide/topics/fundamentals.html#lcycles

On Jun 28, 7:49 pm, Flamechamp flamechamp1...@yahoo.com wrote:
 ermm... can someone show me or give me an URL that shows how to use
 the onDestroy, onPause or onStop??

 I am really beginner and didn't understand how systems in Android are
 running.

 I really appreciate the help

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: Application still consumes battery even tough it is closed

2010-06-26 Thread mahesh
And you have to unregister it in your OnPause() and onStop().

Just as ref if you do not know this already -
OnPause() is called when you quit the application via the back button
or start another app.
OnStop() is called when it is actually killed (via task manager)


-
mahesh
http://android.maheshdixit.com

On Jun 25, 2:25 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Fri, Jun 25, 2010 at 5:21 PM, Flamechamp flamechamp1...@yahoo.com wrote:
  This may sound stupid, but I have a problem with my application.
  I made an application to check the accelerometer and orientation
  sensor.
  I tested it on my Nexus One and it works.
  The problem starts when I close it. (I pressed the - button in the
  phone) When I checked the Battery usage. That program I made is still
  there.

 You also need to be sure to unregister your sensor listeners. If you
 do not, your program will not truly end, and you will continue
 receiving sensor data.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

 _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.6
 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: Application still consumes battery even tough it is closed

2010-06-26 Thread RichardC
Why both onPause() and onStop()?  Looking at the application lifecycle
diagram

http://developer.android.com/images/activity_lifecycle.png

it's not possible to get to onStop() without going through onPause().

If however, you have found this not to be the case, I will have to
change my programs and also deal with possible exceptions from
resources being released twice.

Do you have a simple test as I have never seen this (onPause being
skipped) happen?

/Richard

On 26 June, 17:13, mahesh askmah...@gmail.com wrote:
 And you have to unregister it in your OnPause() and onStop().

 Just as ref if you do not know this already -
 OnPause() is called when you quit the application via the back button
 or start another app.
 OnStop() is called when it is actually killed (via task manager)

 -
 maheshhttp://android.maheshdixit.com

 On Jun 25, 2:25 pm, Mark Murphy mmur...@commonsware.com wrote:

  On Fri, Jun 25, 2010 at 5:21 PM, Flamechamp flamechamp1...@yahoo.com 
  wrote:
   This may sound stupid, but I have a problem with my application.
   I made an application to check the accelerometer and orientation
   sensor.
   I tested it on my Nexus One and it works.
   The problem starts when I close it. (I pressed the - button in the
   phone) When I checked the Battery usage. That program I made is still
   there.

  You also need to be sure to unregister your sensor listeners. If you
  do not, your program will not truly end, and you will continue
  receiving sensor data.

  --
  Mark Murphy (a Commons 
  Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy

  _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.6
  Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en