Previously used a red packet lock screen software, the first time to open the mobile phone appears lock screen, swipe to collect revenue, at that time feel that this function is good, on the access to information, wrote a case,
APK Run Process: Enter the software---"Start the service---" Turn off the phone (you can exit the app first)--"and then turn on the phone to see the lock screen
:
Of course, this case still has shortcomings, did not consider the performance problem.
The interface can be modified at will, and sliding is a custom control.
Service class
Public classAppserviceextendsService {PrivateAppreceiver Mlockscreenreceiver; PrivateIntentfilter Mintentfilter =NewIntentfilter (); @Override Publicibinder onbind (Intent Intent) {//TODO auto-generated Method Stub return NULL; } @Override Public intOnstartcommand (Intent Intent,intFlagsintStartid) { //monitoring screen shutdown and open broadcasts must be dynamically registeredmintentfilter.addaction (intent.action_boot_completed); Mintentfilter.addaction (Intent.action_screen_off); Mintentfilter.addaction (intent.action_screen_on); Mintentfilter.addaction (Intent.action_time_tick); //set the priority of a broadcastmintentfilter.setpriority (Integer.max_value); if(NULL==mlockscreenreceiver) {Mlockscreenreceiver=NewAppreceiver (); Mintentfilter.setpriority (Integer.max_value); Registerreceiver (Mlockscreenreceiver, Mintentfilter); Toast.maketext (Getapplicationcontext (),"Appservice", Toast.length_long). Show (); } notificationcompat.builder Builder=NewNotificationcompat.builder ( This); Builder.setticker ("App is running"); Builder.setautocancel (false); Builder.setcontenttitle ("App is running"); Builder.setcontenttext ("Your earnings are accumulating"); Builder.setlargeicon (Bitmapfactory.decoderesource (Getresources (), r.mipmap.ic_launcher)); Builder.setsmallicon (R.mipmap.ic_launcher); Builder.setcontentintent (Pendingintent.getactivity ( This, 0,NewIntent ( This, Lockscreenactivity.class) , pendingintent.flag_update_current)); Notification N=Builder.build (); //Notification bar display System iconStartforeground (0x111, N); Parser.killbackgroundprocess ( This); returnStart_sticky; } @Override Public voidOnDestroy () {if(Mlockscreenreceiver! =NULL) {unregisterreceiver (mlockscreenreceiver); Mlockscreenreceiver=NULL; } Super. OnDestroy (); //Restart ServiceStartService (NewIntent ( This, Appservice.class)); }}
A bit more source code is not affixed out, directly download the source code can be.
Interested in small partners can refer to, together study.
SOURCE Click Download: Https://github.com/DickyQie/android-system
Android------Lock screen (the lock screen appears on your phone)