Hello Dianne,

My statement was a little misleading. Sorry for that.
Actually i meant not an alarm....but actually a Phone state listener.

The assumption is that my application sends and receives packets over a WiFi
connection only. It does not use the cellular radio interface.
Let me explain my use case in detail. I want to save on device resources by
realizing this use case. These are the steps:

1. My application starts up

2. Now, if my application is idle (there is no incoming/outgoing traffic), i
want to turn the screen off with the CPU still running by taking a
PARTIAL_WAKE_LOCK. (Of course the user may switch to another application and
turn on the screen in the process ! )

(However the docs say that any Wake Lock is bad for the battery !!  I
thought that turning the screen off will save on battery ! )

3. I will have a broadcast receiver that listens to the  ACTION_SCREEN_OFF.
So, when the screen is turned off by my application in idle mode, i will
stop some services that are only needed whenever there is a need to process
calls (incoming and outgoing).

4. Now i will register a phone state listener like this:

TelephonyManager tmgr =
(TelephonyManager)context.getSystemService(context.TELEPHONY_SERVICE);
AppPhoneStateListener myListner = new AppPhoneStateListener();
tmgr.listen(myListner, PhoneStateListener.LISTEN_DATA_ACTIVITY);

// The docs say this data activity is for cellular. Does this mean i cannot
get the state changes to WiFi data traffic ? (Eg: WiFi //connection idle..no
traffic...incoming traffic starts etc)

5. After some time, i will receive a
onDataActivity(int)<http://developer.android.com/reference/android/telephony/PhoneStateListener.html#onDataActivity(int)>
callback
when the data state changes. This is the time, i will initialize resources
to handle the incoming traffic/ or send outbound traffic. Over here, i will
also release the PARTIAL_WAKE_LOCK.

6. Once the call is disconnected, and the application is idle for a certain
period of time, i will repeat the process from Step-2 above.

Is the above scenario feasible ?

Or does it incur a considerable cost on the system battery/resources due to
the PARTIAL_WAKE_LOCK ?

Thanks for your time..


On Wed, Sep 9, 2009 at 10:11 PM, Dianne Hackborn <hack...@android.com>wrote:

> On Wed, Sep 9, 2009 at 1:45 AM, Android Development 
> <indodr...@gmail.com>wrote:
>
>> 1) Suppose, i want my service to go into deep sleep initially. If my phone
>> receives an incoming VoIP call (over the underlying IP connectivity, which
>> may be WiFi), then i wish to start an activity, and alert one of my services
>> to handle  the incoming call. Is there an alarm for which i can register,
>> for implementing this use case ?
>>
>
> Sorry, an alarm for what?  There are broadcasts sent for various things,
> but the platform doesn't natively know anything about VoIP so there wouldn't
> be an alarm or anything for that.  For socket-level communication, you will
> wake up when you are receiving data.
>
> --
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to