"How to develop a lock screen app"
To develop a lock screen application, it seems difficult, in fact, it is not as difficult as imagined.
In essence, the lock screen interface is only an activity, but this interface is very special, when we light the screen, the interface will appear.
And in this interface, we can use some behavior to exit, such as Click button and so on.
There is also a feature in this interface when we are usually unable to use the bottom of the three buttons
About if the three buttons at the bottom of the shield, I have in another blog android4.0+ lock screen Program development-the key block of the summary, the need for friends to see.
In this blog we mainly discuss how to make an activity appear when the screen is lit, and does not trigger the system lock screen.
"Set your own lock screen page"
First, when the screen is lit, the system emits a broadcast, action_screen_on, we can listen to the broadcast through a broadcastreceiver and start our own activity
For example, the following code:
Private New Broadcastreceiver () { @Override publicvoid onreceive (context context, Intent Intent) { = intent.getaction (); if (Action.equals ("Android.intent.action.SCREEN_ON") | | action.equals ("Android.intent.action.SCREEN_OFF")) { startactivity (tomainintent);}} ;
However, light start our activity is not enough, because just start, the system lock screen will still appear in the interface, then the effect becomes, we unlocked the system lock screen to see the custom interface.
This is obviously not what we want to see, we think that when the screen is lit, we can see our interface.
This requirement can be achieved by turning off the system lock screen in the settings of the custom interface.
The code is as follows:
protected void onCreate (Bundle savedinstancestate) { super. OnCreate (savedinstancestate); Final Window win = GetWindow (); Win.addflags ( | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // Unlock the system lock screen Setcontentview (r.layout.main_layout); Setview (); // Set Close button }
With the above settings, we can see our interface when the screen is lit.
An example of a complete lock screen I've uploaded to GitHub with the address: https://github.com/u3shadow/ScreenLockTest
A friend in need can make a reference.
Through these two blog, we can basically implement a lock screen application, on this basis, we can do a further optimization of the custom interface, landscaping, to make their own ideal lock screen.
This series is here, hope to help everyone, thank you
android4.0+ Lock Screen Program development--Set the lock screen page