[android-developers] Re: launch activity like phone call

2009-09-28 Thread sleith

ok thanks for the explanation. i learn more :D

On Sep 28, 8:13 pm, Mark Murphy  wrote:
> sleith wrote:
> > Hi,
> > wanna ask again about Mark's first warning:
> > " Your service will not be running for very long once the screen turns
> > off. The phone will go to sleep, and your service will stop running
> > when
> > the phone turns off the CPU. "
>
> > when the phone turns on the CPU again, will the service restarted
> > automatically?
>
> "Restarted"? A running service will start running again, but to me
> "restart" implies it was destroyed and recreated, which does not happen.
>
> When the CPU shuts down, everything freezes in mid-operation. When the
> CPU starts up again, everything continues from where it was.
>
> Again, I strongly advise against having services run indefinitely. A
> well-constructed service only runs when it needs to (via an alarm) and
> can arrange via a WakeLock to keep the CPU running for the short period
> it needs to run. See more at:
>
> http://www.androidguys.com/2009/09/09/diamonds-are-forever-services-a...
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Development Wiki:http://wiki.andmob.org
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: launch activity like phone call

2009-09-28 Thread Mark Murphy

sleith wrote:
> Hi,
> wanna ask again about Mark's first warning:
> " Your service will not be running for very long once the screen turns
> off. The phone will go to sleep, and your service will stop running
> when
> the phone turns off the CPU. "
> 
> when the phone turns on the CPU again, will the service restarted
> automatically?

"Restarted"? A running service will start running again, but to me
"restart" implies it was destroyed and recreated, which does not happen.

When the CPU shuts down, everything freezes in mid-operation. When the
CPU starts up again, everything continues from where it was.

Again, I strongly advise against having services run indefinitely. A
well-constructed service only runs when it needs to (via an alarm) and
can arrange via a WakeLock to keep the CPU running for the short period
it needs to run. See more at:

http://www.androidguys.com/2009/09/09/diamonds-are-forever-services-are-not/

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

Android Development Wiki: http://wiki.andmob.org

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: launch activity like phone call

2009-09-28 Thread sleith

Hi,
wanna ask again about Mark's first warning:
" Your service will not be running for very long once the screen turns
off. The phone will go to sleep, and your service will stop running
when
the phone turns off the CPU. "

when the phone turns on the CPU again, will the service restarted
automatically?
if it won't, how to know if the CPU has been turned on/off?

thanks

On Sep 27, 5:35 pm, sleith  wrote:
> Hi,
> thanks Mark for your advice, that's a nice input from you :)
>
> On Sep 27, 5:26 pm, Mark Murphy  wrote:
>
> > sleith wrote:
> > > i've tested when the phone screen is off, the service is still
> > > running, but when the service try to start intent, the screen is still
> > > not shown because it's off. when the screen is on again, i can see the
> > > intent that was launched by service.
> > > is there any way to make the screen on by programming? because when we
> > > receive call, the screen will on. so i think it is possible :D
>
> > First, the warnings:
>
> > 1. Your service will not be running for very long once the screen turns
> > off. The phone will go to sleep, and your service will stop running when
> > the phone turns off the CPU.
>
> > 2. Doing things that wake up the phone are bad for battery life. See
> > Jeff Sharkey's "Coding for Life...Battery Life, That Is" presentation
> > from Google I/O 2009 for statistics.
>
> > 3. Popping up user interfaces from a service are bad for the user
> > experience. If the user is, say, in the middle of typing a text message,
> > and your service-spawned activity steals the foreground, they may have
> > quite a few profanities to fling in your direction. An incoming phone
> > call is one of the few things users might tend to agree warrants such an
> > intrusion...and I suspect there are still many a curse word used when
> > users get interrupted, even for that.
>
> > Hence, before you even bother with any code, you need to really make
> > sure that this is what you want to do, and consider offering user
> > preferences to disable this functionality.
>
> > All that said, you will want to look at PowerManager.WakeLock to arrange
> > to keep the screen and CPU on for a while. Which leads to:
>
> > 4. Misusing WakeLocks are horrible for the battery. Do not leak an
> > acquired WakeLock.
>
> > --
> > Mark Murphy (a Commons 
> > Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> > Android Training in Germany, 18-22 January 2010:http://bignerdranch.com
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: launch activity like phone call

2009-09-27 Thread sleith

Hi,
thanks Mark for your advice, that's a nice input from you :)

On Sep 27, 5:26 pm, Mark Murphy  wrote:
> sleith wrote:
> > i've tested when the phone screen is off, the service is still
> > running, but when the service try to start intent, the screen is still
> > not shown because it's off. when the screen is on again, i can see the
> > intent that was launched by service.
> > is there any way to make the screen on by programming? because when we
> > receive call, the screen will on. so i think it is possible :D
>
> First, the warnings:
>
> 1. Your service will not be running for very long once the screen turns
> off. The phone will go to sleep, and your service will stop running when
> the phone turns off the CPU.
>
> 2. Doing things that wake up the phone are bad for battery life. See
> Jeff Sharkey's "Coding for Life...Battery Life, That Is" presentation
> from Google I/O 2009 for statistics.
>
> 3. Popping up user interfaces from a service are bad for the user
> experience. If the user is, say, in the middle of typing a text message,
> and your service-spawned activity steals the foreground, they may have
> quite a few profanities to fling in your direction. An incoming phone
> call is one of the few things users might tend to agree warrants such an
> intrusion...and I suspect there are still many a curse word used when
> users get interrupted, even for that.
>
> Hence, before you even bother with any code, you need to really make
> sure that this is what you want to do, and consider offering user
> preferences to disable this functionality.
>
> All that said, you will want to look at PowerManager.WakeLock to arrange
> to keep the screen and CPU on for a while. Which leads to:
>
> 4. Misusing WakeLocks are horrible for the battery. Do not leak an
> acquired WakeLock.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Training in Germany, 18-22 January 2010:http://bignerdranch.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: launch activity like phone call

2009-09-27 Thread Mark Murphy

sleith wrote:
> i've tested when the phone screen is off, the service is still
> running, but when the service try to start intent, the screen is still
> not shown because it's off. when the screen is on again, i can see the
> intent that was launched by service.
> is there any way to make the screen on by programming? because when we
> receive call, the screen will on. so i think it is possible :D

First, the warnings:

1. Your service will not be running for very long once the screen turns
off. The phone will go to sleep, and your service will stop running when
the phone turns off the CPU.

2. Doing things that wake up the phone are bad for battery life. See
Jeff Sharkey's "Coding for Life...Battery Life, That Is" presentation
from Google I/O 2009 for statistics.

3. Popping up user interfaces from a service are bad for the user
experience. If the user is, say, in the middle of typing a text message,
and your service-spawned activity steals the foreground, they may have
quite a few profanities to fling in your direction. An incoming phone
call is one of the few things users might tend to agree warrants such an
intrusion...and I suspect there are still many a curse word used when
users get interrupted, even for that.

Hence, before you even bother with any code, you need to really make
sure that this is what you want to do, and consider offering user
preferences to disable this functionality.

All that said, you will want to look at PowerManager.WakeLock to arrange
to keep the screen and CPU on for a while. Which leads to:

4. Misusing WakeLocks are horrible for the battery. Do not leak an
acquired WakeLock.

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

Android Training in Germany, 18-22 January 2010: http://bignerdranch.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: launch activity like phone call

2009-09-27 Thread sleith

Hi, thanks for your fast response :D
how about the questions number 1?
i've tested when the phone screen is off, the service is still
running, but when the service try to start intent, the screen is still
not shown because it's off. when the screen is on again, i can see the
intent that was launched by service.
is there any way to make the screen on by programming? because when we
receive call, the screen will on. so i think it is possible :D

thank you

On Sep 27, 3:50 pm, Dianne Hackborn  wrote:
> On Sun, Sep 27, 2009 at 1:47 AM, sleith  wrote:
> > 2. how to start a service right after downloaded and installed from
> > android market?
>
> This is deliberately not supported.  You can start the service when the user
> launches your app.
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: launch activity like phone call

2009-09-27 Thread Dianne Hackborn
On Sun, Sep 27, 2009 at 1:47 AM, sleith  wrote:

> 2. how to start a service right after downloaded and installed from
> android market?
>

This is deliberately not supported.  You can start the service when the user
launches your app.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---