Android------Lock screen (lock screen on phone boot)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.