How to find out if device is in sleep mode?

by JP » Tue, 26 May 2009 14:13:56 GMT

Sponsored Links
 I am sure it is buried in the SDK somewhere... but I couldn't find it.
This is relevant to a service running in the background: How can I
find out if the device is in sleep mode?


How to find out if device is in sleep mode?

by Mark Murphy » Tue, 26 May 2009 18:07:21 GMT


If your code is in position to ask the question, you're not in sleep
mode... ;-)

Mark Murphy (a Commons Guy)  | 

Warescription: Three Android Books, Plus Updates, $35/Year


Sponsored Links

How to find out if device is in sleep mode?

by JP » Tue, 26 May 2009 21:30:57 GMT

 Well nomenclature...

Here's the scenario: I've got an app that implements the relevant data
processing and backend server connectivity through a Service that I
keep running on a reduced ("sleep") activity level when the user puts
the device to sleep (using end button) or when the screen timeout
hits. I can follow this status change, because it triggers calls to
overloaded onStop() and onPause() methods of the app's subclassed
Activity. This way, I control active/reduced ("sleep") activity levels
of that Service. Everything's cool and dandy in this scenario.

Enter an AppWidget that's using this Service in a similar fashion,
with functionality implemented in a subclass of AppWidgetProvider.

This changes the game - I have found no way to determine when to set
the Service to the reduced ("sleep") activity level from that point.
The app's Activity has long paused, and I keep the Service at active
level, as the widget needs updates from the Service similar to what
the Activity needs when in front. With the AppWidget on the home
screen, I want, and should (re: battery life), drop the Service's
activity level when the device enters sleep mode. The most elegant way
to handle this would be to detect whether the device sleeps (or, on
second thought, better actually, whether the display is dark) right
inside the Service. This way, as a side product, I can also drop
following the device status in the overloaded onStop(), onPause(),
onStart() and onResume() methods.


Other Threads

1. System Administrator with Active Directory, AZ


Hope you are doing well!!

I have an urgent requirement with one of my client . If you are
comfortable with the following requirement then please send me your
updated resume along with contact details ASAP.

Active Directory
Location: Tempe, AZ
Duration: 4 Months

- 5+ years of Active Directory experience
- Level 3 Active Directory Administration/Architecture skills
- Good AD troubleshooting skills
- Good AD design skills
- Extensive GPO configuration experience
- Extensive Active Directory experience in a multi-domain forest
- Windows 2008 Server working experience
- Windows 2003 Server working experience
- Good DNS experience
- Optional - Microsoft Certification

a.            Strong Active Directory troubleshooting skills
b.            Strong Active Directory design and administrations
c.             Good GPO knowledge
d.            Sound knowledge of Windows server 2003 and 2008
e.            DNS / DHCP
f.             Exposure to Dell Server hardware.

1.            MCSE certification  valued

Key skills required:
1) Windows 2008/2003 Servers administration in Active Directory.
2) GPO experience
3) AD experience in multi domain environment


Junaid Alam
Technical Recruiter
Phone: 609-897-9670 Ext 213
Fax: 302-269-7171

SysMind LLC | 38 Washington Rd | Princeton Jn, NJ-08550 |


2. Not able to find adb.exe

Hi all,
I am new to Android. I have downloaded all the SDK Components from SDK
Installer. I am using ecllipse Ganymede. Also, I have installed
ADT-10.0.1 in ecllipse. But when I browse my sdk location in Window >
Preferences > Android, it is showing error as 'Could not find adb.exe
in Adroid-SDK\tools\'. In my Android sdk, adb.exe is located inside
'Android-SDK\platform-tools\' directory. How can I able to change this
adb.exe file path? I have included Android-SDK\platform-tools\
directory in PATH variable.
Anybody please help me out.



3. in app billing: PURCHASE_STATE_CHANGED sends empty orders

4. Phone crash on volume key

5. Mixing of voice

6. RatingBar

7. Segmentation fault when loading a certain class from an OSGi framework under Android 2.2 & 2.3