The basic function of the program lock has been implemented, but if you enter the password to enter the app, the watchdog, or listen to the app you want to enter, then there will be a password to enter the interface.
Let me first talk about the idea.
① Ideas1. By sending a custom broadcast in the service, monitoring more than one judge if the program is temporarily de-protected to start the program lock, this time, we have to solve is when to let him start monitoring, the answer is the lock screen. 2. Set the zero protection value to null through the lock screen to continue protecting the
But there's still a bug there. Return key to cancel the input password interface, you can slowly read the interface content, how to solve itThe solution is: 3. If the input password interface, the return can slowly read the content, so we monitor the return key, if returned directly back to the desktop 4. If the information entered in the password is displayed in the other locked app, then we'll finish off the activity by OnStop.OK Because this application I wrote in the test project source code in the back to provide everyone just directly to find AppManager that part of the codes on the line
Solution one in Enterpwdactivity.java
Tell the watchdog that the password for this program is entered correctly. You can temporarily stop the protection. Custom broadcasts, temporary stop protection. Intent Intent = new Intent () intent.setaction ("Com.xiaoxin.mobilesafe.tempstop"); Intent.putextra ("Packname", Packname); Sendbroadcast (intent); finish ();
Watchdogservice.java then accepts a custom broadcast to make a deal register a broadcast recipient
Private Innerreceiver Innerreceiver;
Innerreceiver = new Innerreceiver (); Registerreceiver (Innerreceiver, New Intentfilter (" Com.xiaoxin.mobilesafe.tempstop "));
Private class Innerreceiver extends broadcastreceiver{@Overridepublic void onreceive (context context, Intent Intent) { Tempstop = Intent.getstringextra ("Packname");}}
The service is processed,
Also determine if the application temporarily stops protecting if (Packagename.equals (Tempstop)) {}
Don't do anything if you're not listening to the app
Solution two listen to the lock screen when the broadcast
Private Screenoffreceiver Offreceiver;
Private class Screenoffreceiver extends Broadcastreceiver {@Overridepublic void OnReceive (context context, Intent Intent {offreceiver = null;}}
<span></span>offreceiver = new Screenoffreceiver (); <span></span>registerreceiver ( Offreceiver, New Intentfilter (Intent.action_screen_off));
Solution three back to the code that entered the password interface
@Overridepublic void onbackpressed () {//back to the desktop. Intent Intent = new Intent () intent.setaction ("Android.intent.action.MAIN"); Intent.addcategory (" Android.intent.category.HOME "), Intent.addcategory (" Android.intent.category.DEFAULT "); Intent.addcategory (" Android.intent.category.MONKEY "); StartActivity (intent);//All activity minimization does not execute ondestory only the OnStop method is executed. }
@Overrideprotected void OnStop () {super.onstop (); Finish ();}
Practiced hand small item (5) Security Defender _ program lock bug fix One