Friday, March 28, 2014

android4.0 custom lock screen apk summary form


Well, get on, talk about lock screen, in fact, made the lock screen apk form, it will cause a lot of problems, resulting in unnecessary trouble, as the market The popular Go lock screen and lock screen 91 also have some problems, but little effect, the best practice is to modify the source code to customize their lock screen in the source code, so that once and for all;

First thing to do considering the lock screen has the following four points;

(1) replace the system lock screen, you can not let the system lock screen displays;

(2) masked Home keyboards, back button, menu button;

(3) In other interface or Launcher screen, press the home button, you can not make your own lock screen apk displayed in a recent task;

(4) each boot to show their lock screen




Eleven answers to these four points do not necessarily complete code, but offers the following ideas, interested students can ask questions;

for (1) , this is relatively easy, it calls disableKeyguard out system on it;


 [java] view plaincopyprint? 
mKeyguardManager = (KeyguardManager) Class.this.getSystemService (Context.KEYGUARD_SERVICE);
mKeyguardLock = mKeyguardManager.newKeyguardLock ("my_lockscreen");
mKeyguardLock.disableKeyguard ();
NOTE: Adding permissions Manifext.xml in:



for (2) , to deal with the Home key, I think the Internet has students write a blog, and some students are so processed:

[Java] view plaincopyprint?

Principle: It is wrong to view this as a view of the system, sdk documentation there is an explanation,

Window type: internal system error windows, appear on top of everything they can In multiuser systems shows only on the owning user's window
..
The error of the view at the top of all the view, so you can achieve the effect of shielding the home button, but the long press power button to shut down the interface on the shells do not come out, I tried this, so this method is not desirable;

There do students say:

private static final int FLAG_HOMEKEY_DISPATCHED = 0x80000000;

 public class LockLayer {
private Activity mActivty;
private WindowManager mWindowManager;
private View mLockView;
private LayoutParams mLockViewLayoutParams;
private static LockLayer mLockLayer;
private boolean isLocked;

public static synchronized LockLayer getInstance (Activity act) {
if (mLockLayer == null) {
mLockLayer = new LockLayer (act);
}
return mLockLayer;
}

private LockLayer (Activity act) {
mActivty = act;
init ();
}

private void init () {
isLocked = false;
mWindowManager = mActivty.getWindowManager ();
mLockViewLayoutParams = new LayoutParams ();
mLockViewLayoutParams.width = LayoutParams.MATCH_PARENT;
mLockViewLayoutParams.height = LayoutParams.MATCH_PARENT;
/ / Key to achieving
mLockViewLayoutParams.type = LayoutParams.TYPE_SYSTEM_ERROR;
/ / Apktool value, the value of specific variables which also requested help users
mLockViewLayoutParams.flags = 1280;
}
public synchronized void lock () {
if (mLockView! = null &&! isLocked) {
mWindowManager.addView (mLockView, mLockViewLayoutParams);
}
isLocked = true;
}
public synchronized void unlock () {
if (mWindowManager! = null && isLocked) {
mWindowManager.removeView (mLockView);
}
isLocked = false;
}
public synchronized void setLockView (View v) {
mLockView = v;
}
}

To shield your home button in the activity app, you only need to add the logo on it

. getWindow () addFlags (WindowManager.LayoutParams.FLAG_HOMEKEY_DISPATCHED);

If you want the home key is valid, then clearFlags can.

getWindow () clearFlags (WindowManager.LayoutParams.FLAG_HOMEKEY_DISPATCHED);.
Note: The above code to be added to the setContentView () before the job;

This code comes from PhoneWindowManager.java this class,

[Html] view plaincopyprint?
if ((flag & WindowManager.LayoutParams.FLAG_HOMEKEY_DISPATCHED)! = 0) {
/ / The window wants to handle the home key, so dispatch it to it.
return 0;
}
This setting, some students feel easy to use, with some students feel bad reasons: android4.0 source of PhoneWindowManager.java did not add the above code, so do not work, and 4.1 have the source code PhoneWindowManager.java So easy to use, the corresponding source code, please take a look at whether the above code;
for (3) , this would mimic Go lock screen lock screen and 91, the configuration

this property, then the system to clear the default settings, click the Home key is to choose the system which started home, is set to launch its own lock screen, and then After setting start unlocking the desktop, under this deal with their own logic on it, the general idea is like this;

for (4) , the Go lock screen lock screen as well as 91 treatment are less than ideal, looking back, I think a good idea and then update, the general idea is: listen boot broadcast, , write a MYBootCompletedReceiver this class, is to disable the lock screen off the system, then start your own lock screen services, monitor screen turn on and off the radio, turn on and off the screen broadcast to dynamically monitor; everyone has good ideas can leave a message to discuss?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Thanks for sharing a key lock screen has done a 365 call of a key lock screen
Reply:
Thanks for sharing the doorway with a lot of ah learned
Reply:
Thanks for sharing learn!
Reply:
Thanks for sharing doorway learn a lot of ah
Reply:
4.11 do these answers, not necessarily the complete code, but offers the following ideas, interested students can ask questions;

Reply:
Thanks for sharing learn!
Reply:
Yeah amazing people here.
Reply:
Very detailed and learn it.

Reply:

Very detailed and learn it.


        


Reply:
Yes, yes
Reply:
Their own learning, thank you
Reply:
Hello, I use the 4.1 SDK, but still can not find FLAG_HOMEKEY_DISPATCHED this logo on the home button all tangled 4.1 shield for some time, but still no progress, seeking advice
Reply:
The reply was deleted administrator at 2013-04-23 15:52:49

Reply:
The reply was deleted administrator at 2013-04-23 16:47:37

Reply:
Support! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Reply:
Haoyahaoya support the sharing of good experiences
Reply:
references
Hello, I used 4.1 SDK, but still can not find FLAG_HOMEKEY_DISPATCHED this logo on the home button all tangled 4.1 shield some time , but still no progress, seeking advice

This shielding the Home key, you can try this: their definition in the Activity:
private static final int FLAG_HOMEKEY_DISPATCHED = 0x80000000;
Then add
in setContentView () before. getWindow () addFlags (WindowManager.LayoutParams.FLAG_HOMEKEY_DISPATCHED); This code;
If the framework of PhoneWindowManager.java have
 if ((flag & WindowManager.LayoutParams.FLAG_HOMEKEY_DISPATCHED)! = 0) {
/ / The window wants to handle the home key, so dispatch it to it.
return 0;
}

This code can shield the Home key.
Reply:
Landlord, hello, you can add your Q? Hope to get some more of your pointing (Q: 403060188)
Reply:
Since identity is defined in the Activity FLAG_HOMEKEY_DISPATCHED, and setConentView () before adding the getWindow () addFlags (WindowManager.LayoutParams.FLAG_HOMEKEY_DISPATCHED);. After the code, then run the screen goes black, and the home button is still used, is it because framework The PhoneWindowManager.java is not that part of it?
Reply:
Now there is not a lot of flat screen lock function?
Reply:
references
custom logo FLAG_HOMEKEY_DISPATCHED in the Activity and setConentView () before adding the getWindow () addFlags (WindowManager.LayoutParams.FLAG_HOMEKEY_DISPATCHED);. code Then, after running the screen goes black, and the home button is still used, is it because there is no framework for PhoneWindowManager.java period it?

You try this
private static final int FLAG_HOMEKEY_DISPATCHED = 0x80000000; in setConentView () before adding
this.getWindow () setFlags (FLAG_HOMEKEY_DISPATCHED, FLAG_HOMEKEY_DISPATCHED).;
Reply:
Do not understand, passing
Reply:
Good complex ah, amazing!
Reply:
very detailed and learn it.
Reply:
The reply was deleted administrator at 2013-04-24 09:05:04

Reply:
Worth learning, then went to do this trip, and,
Reply:
Worth learning, very good
Reply:
The top one, thank you for sharing!
Reply:

Reply:
Sharing is a blessing! !
Reply:
Thanks for sharing learn!!
Reply:
After the trial or before the appearance of the problem, home button can not be shielded
Reply:
private static final int FLAG_HOMEKEY_DISPATCHED = 0x80000000;
Plus
in setConentView () beforethis.getWindow () setFlags (FLAG_HOMEKEY_DISPATCHED, FLAG_HOMEKEY_DISPATCHED);.

Landlord, I do as you say, or blank screen, home button would still not be masked. Hope to get your advice again.

Reply:
 private static final int FLAG_HOMEKEY_DISPATCHED = 0x80000000; 
Plus
in setConentView () beforethis.getWindow () setFlags (FLAG_HOMEKEY_DISPATCHED, FLAG_HOMEKEY_DISPATCHED);.

Landlord, I do as you say, or blank screen, home button would still not be masked. Hope to get your advice again.


Then you spend a method, you can refer to my blog android4.0 custom lock [android screen lock screen summarizes a study]
Reply:
Support
Reply:
Thanks for sharing the doorway with a lot of ah
Reply:
Thanks for sharing doorway learn a lot of ah
Reply:
Well, good, but the first method and the second method is the same result occurs ------ screen goes black
Reply:
Good for you worth learning ah
Reply:
Thank you, landlord I need these
Reply:
The landlord, you said the two methods are tried, are running the screen goes black, you, and you learn the faithful encountered such a situation it
Reply:
Learn. Thank you
Reply:
The reply was deleted administrator at 2013-04-25 08:52:35

Reply:
Learn about, have been using millet lock screen, but no V5, and see if I can do one yourself
Reply:
The reply was deleted administrator at 2013-04-25 11:07:12

Reply:
Very very strong. . . .
Reply:
Very powerful, but I will not, Kazakhstan
Reply:

Reply:
Take a look at this, look at
Reply:
Thanks for sharing learn!

No comments:

Post a Comment