Android Lock Screen Program development

Source: Internet
Author: User

Reference http://blog.csdn.net/wdaming1986/article/details/8837023

锁屏程序的步骤如下:1、替换系统锁屏2、屏蔽Home键,back键、menu键3、锁屏程序不出现在最近任务列表中4、屏幕唤醒时显示锁屏界面

First, replace the system lock screen

Most of the research market lock Screen program, will guide users to turn off the system lock screen. When the user does not turn off the system lock screen, we can overwrite our custom lock screen program on the System lock screen program to unlock the system lock screen.

The following are the specific practices:

API level is less than 13 o'clock:

Mkeyguardmanager = (Keyguardmanager) context.getsystemservice (Context.keyguard_service);

Mkeyguardlock =mkeyguardmanager.newkeyguardlock ("Fxlock");

            // 屏蔽手机内置的锁屏            if (Build.VERSION.SDK_INT < 13) {                mKeyguardLock.disableKeyguard();            }

More than 13 o'clock, we set the window for the custom lock screen to add WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD tags

2. Shielded Home button

Back, Menu key we can block in the OnKey () function. The home key cannot be blocked in a normal way for system security reasons

The following are the current ways to learn:

1, 2.3 below system

@Override

public void Onattachedtowindow () {

    System.out.println("Page01 -->onAttachedToWindow");    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);     super.onAttachedToWindow();

}

2, 4.0 system

static final int flag_homekey_dispatched = 0x80000000;

GetWindow (). SetFlags (flag_homekey_dispatched, flag_homekey_dispatched)

3, 4.0 above system

Pop-up TYPE WindowManager.LayoutParams.TYPE_SYSTEM_ERROR

The dialog box (the specific principle can refer to Phonewindowmanager.java) This way is said to be invalid in the millet, Meizu and other systems (measured MIUI6 invalid, Huawei Mobile Phone is valid)

The above 3 solutions are all from the Internet, the actual research found that the lock screen application of the Snap efficiency lock screen is now doing better. By deserializing its code, it can be found that it uses a third solution, and that the Xiaomi and Meizu systems are individually adapted.

3, the lock screen application does not present the task list

This adds android:excludefromrecents= "true" to the manifest

4. Screen wake-Up Display custom lock screen

The current general practice is to start a background service, registering a broadcast receiver in the service (intent.action_screen_on, Intent.action_screen_off, Intent.action_boot_ Completed, Intent.action_close_system_dialogs)

After receiving the INTENT.ACTION_SCREEN_ON broadcast, start the custom lock screen

Receive Intent.action_close_system_dialogs Broadcast (press and hold the Power key) to hide the TYPE WindowManager.LayoutParams.TYPE_SYSTEM_ERROR dialog box, This allows you to display the System Shutdown dialog box.

Android Lock Screen Program development

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.