Android launch intent when lockscreen should appear

纵饮孤独 提交于 2019-11-28 09:44:09

问题


I am trying to develop a alternate lock screen there for I need a intent filter which listens on the screen going off

but the problem is I don't know which attribute to use and which value to give


回答1:


Working on the same thing as well.

this is the question i posted yesterday, follow it maybe something will pop out.

By the way as i wrote in the question, the action you have to listen to are:

  • Intent.ACTION_SCREEN_ON: screen is on, you have to start your activity here and check for inKeyguardRestrictedInputMode this method to be sure that the keyguard ( lockscreen ) is open.
  • Intent.ACTION_SCREEN_OFF: this is the event sent when the screen goes off, do whatever you need here.
  • Intent.ACTION_USER_PRESENT: this is instead sent when the user unlock the secure keyguard like.

An important thing to know are these 2 flangs:

  • WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED:
  • WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD

use them in your lockscreen activity to be able to have it when the screen is locked and to dismiss keyguards when they are not secure.

hope this help, there is a huge lack of documentation on android lockscreen customization.




回答2:


You need an InternFilter that listens to Intent.ACTION_SCREEN_OFF action.

IntentFilter screenFilter = new IntentFilter();
screenFilter.addAction(Intent.ACTION_SCREEN_OFF); 


来源:https://stackoverflow.com/questions/10767768/android-launch-intent-when-lockscreen-should-appear

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!