2011年10月29日 星期六

[Android] 螢幕保護

Want To

就像電腦的螢幕保護程式,當手機閒置一段時間,不會鎖螢幕或是螢幕暗下來

而是顯示我們想要的內容,例如輪播照片之類的


Try To

[Lock Screen/Keyguard]
  • 取代系統原有的 Lock Screen/Keyguard
    • May Relative API
      • DevicePolicyManager
      • KeyguardManager
      • WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
    • Issues:
      • What is the different between Lock Screen and Keyguard means?
      • Keyguard includes 螢幕鎖和圖案解鎖等。(refer. 1)
      • Many events should be considered, ex:
        • Screen off/on, Incoming call/SMS, Alert Message.....
      • 是否可以在原有的 Lock Screen/Keyguard 上再執行自己的 application?
  • Disable Lock Screen/Keyguard and using Service or Thread to record touch event. 如果事件間隔超過設定,則啟動 Activity。
    • Events handler problems.
    • Start Activity in Service is allowed?
// Using KeyguardManager can disable/re-enable keyguard
KeyguardManager mKeyguardManager = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE); 
KeyguardLock mKeyguardLock = mKeyguardManager.newKeyguardLock("Activity1"); 
mKeyguardLock.disableKeyguard(); 



[Live Wallpaper]
  • Live wallpaper still showing when screen is locked,所以若是僅顯示在螢幕鎖之下即可...
    • 動態設定 live wallpaper,也就是當螢幕鎖了,才設定(因為應該要不影響 user 原有的桌步設定),取消後恢復 user 原有設定。
    • 但沒有正式官方的相官 method。


* Reference
  1. android的KeyGuard_谢彦_新浪博客
  2. [Android]替换系统的Lock Screen - sunny09290的专栏 - 博客频道 - CSDN.NET
  3. Handling Screen OFF and Screen ON Intents

沒有留言:

張貼留言