`

[AndroidTips]Android how to check screen off 判断屏幕是开还是关

 
阅读更多
pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
boolean screen = pm.isScreenOn();

 

如果你要监听屏幕开关的事件的话, 你需要监听这个两个ACTION_SCREEN_OFF and ACTION_SCREEN_ON intent broadcast

 

ref:http://stackoverflow.com/questions/7529733/how-to-discover-if-the-screen-is-on-or-off-while-developping-in-android

分享到:
评论

相关推荐

    Android代码-Wownerujo

    Wownerujo An Android Wallet for Wownero QUICKSTART ...If you want to build the external libs yourself (recommended) check out the instructions. Then, fire up Android Studio and build t

    一本android的好书beginning android 2 和 源码

    And How Do We Attach These to the Java? The Rest of the Story ■Chapter 5: Employing Basic Widgets Assigning Labels Button, Button, Who’s Got the Button? Fleeting Images Fields of Green Or Other ...

    VB编程资源大全(英文源码 控制)

    right click and you should see "Rem Builder".<END><br>3 , syntax.zip This is an excellent example of how to highlight HTML code in a rich textbox. I encourage everyone to check it out.<END><br>4 ...

    Arduino Projects For Dummies

    Well, first of all I'd check out the Arduino website to get a good idea of what Arduino is all about and what it can do. Then, I'd grab a copy of Arduino For Dummies, by my friend John Nussey and try ...

    VB编程资源大全(英文源码 其它)

    <END><br>28 , calc.zip This is a basic calculator written in Visual Basic.<END><br>29 , stopwatch.zip This shows how to count off time in a Stop Watch format.<END><br>31 , taskhide.zip This ...

    VB编程资源大全(英文源码 表单)

    1 , manc-skinex.zip This is an example of how to add skins to your program.<END><br>2 , irregularForms.zip This is a great example. It takes two images to shape the form, then blits the "face" ...

    窗口大小调整软件

    Added StickyScreen which makes windows automatically stick to the screen borders without needing shift (off by default). Added the ability to roll-up windows by double-clicking with the middle mouse ...

    Visual C++ 编程资源大全(英文源码 控件)

    (49KB)<END><br>25,fully.zip FULLY shows how to make an MFC application make one of its views go full-screen active. (43KB)<END><br>26,holder.zip HOLDER contains the Internet Explorer web ...

    iOS-2048-master

    Check out the related files to see how that is done, if you are curious. You should be able to download the source, and build and run without problem. However, please note that you may not want to ...

    VB编程资源大全(英文源码 网络)

    <END><br>23 , RemoteFileExp.zip This utility allows you to remotely reboot, log-off, 下载 files, delete files,luanch applications, auto navigate a web browser and view desktops via TCP/IP<END><br>...

    微软内部资料-SQL性能优化2

    Before we look at how SQL Server uses and manages its memory, we need to ensure a full understanding of the more common memory related terms. The following definitions will help you understand how SQL...

    ViewPager 放大缩小左右移动

    实现 图片的放大,缩小,左右屏幕滑动 。 直接贴代码吧。。 public class ViewPager extends ViewGroup { private static final String TAG = "ViewPager"; private static final boolean DEBUG = false; ...

    VB编程资源大全(英文控件)

    1,animate.zip This ActiveX DLL (Source Included) shows how to create animated dialogs in VB5. <END><br>2,MetricConversionDLL.zip 34 Metric conversion routines in a VB5 DLL. Callible directly or ...

    Turbo C++ 3.0[DISK]

    Welcome to Turbo C++ Version 3.0 -------------------------------- This README file contains important information about Turbo C++. For the latest information about Turbo C++ and its accompanying ...

    Turbo C++ 3.00[DISK]

    Welcome to Turbo C++ Version 3.0 -------------------------------- This README file contains important information about Turbo C++. For the latest information about Turbo C++ and its accompanying ...

    端口查看工具

    o The 'Use DNS Cache For Host Names' option is now turned off by default, because it seems that reading the DNS cache causes a memory leak on some Windows 7/x64 systems. * Version 1.96: o Fixed ...

    matlab做软件界面

    Shortcuts 2 Whar's lew L How to-y GUIDE FLEAR E] CLOSE ALL S BOR Currenl Dirurluiy-C-WHATLAB7Iwwurk p x Cultu wfildluw [朝马 山Fit F 当A|Dl DCOLMUNCATIONS IconO GUIDe Se presenta el siguiente cuadro ...

Global site tag (gtag.js) - Google Analytics