Developing a Custom Lock Screen

Developing a custom lock screen

There is no support for creating a "custom lock screen aap" in the Android SDK. You can only modify the lock screen behavior in custom firmware.

UPDATE

Note that Android 4.2 does allow you to create app widgets that can be added to the device's lockscreen, which may meet your needs.

Create custom LockScreen for Android

At the end I managed to make this app working. My biggest problem was to put my device in kiosk mode (disabling hardware buttons when the lockscreen is displayed). The solution that worked for me was enabling device owner mode using Android Debug Bridge. It wasn't the best solution, but it was the most acceptable one for this project.

Here are some of the links that I used to achieve this:

https://documentation.meraki.com/SM/Device_Enrollment/Enabling_Device_Owner_Mode_using_Android_Debug_Bridge_(ADB)

http://www.sureshjoshi.com/mobile/android-kiosk-mode-without-root/

Custom Lock Screen Implementation Techniques

I would use the first method, but only for usability reasons. Because it gives the user a choice to easily revert back to the original homescreen/lockscreen if he chooses not to make the new one a default choice yet.

I'm afraid both strategies you described are quite difficult (depending on the api level range you want it to work on). The difficulty is not in their difference, the difficulty is in overriding the buttons (as Google makes it more difficult by closing down security loopholes for the newer api levels).

PS: Please note that Jellybean has a new Daydream functionality. If customizing the lockscreen is all you need. That may be the way to go since Jellybean is much more secure in that respect and more difficult to work with than the previous api levels otherwise.

Also, consider using the HTC screenlock api for HTC devices. This way, your solution won't be too hacky at least for their newer devices. And perhaps, do a version for rooted devices as well, since that too should be easy, for users who already have obtained root on their device. Don't discount the rooted market, users with root access do spend a disproportionate amount of money on applications in Google Play. That much is obvious if you just take a look at some of the rough numbers of downloads for paid applications that say (for root only) that Google Play gives you.

How to customize Android's LockScreen?

Have a look at this answer. You need to write your own home screen app which will implement the lockscreen behaviour that you require. There is sample code for writing your own home screen app in the Android SDK.

Create custom lockscreen for android 4.0 or above?

I have found snippets somewhere on internet few months ago, I have made changes and recently uploaded the working demo on my github account, You can have a look at this

Note:
It will disable "hardware" home button.

I hope it will be helpfull !!

Screenshots:

It provides lockscreen in API 8 or above.

Initial

Alt text

Locked

Alt text

Unlocked

Alt text

How to create a custom lock screen widget (I just want to display a button)

API Levels

Lock-screen widgets were introduced in API 17 (4.2), and removed in API 21 (5.0). They are not supported on other official releases.


Basic Widget

I wrote a simple widget as a demo tutorial - it contains all the boilerplate code required for a widget, and very little else:

  • WiFi Widget Demo (github)
  • WiFi Widget (Play store)

I wrote it in such a way to make it easy for anyone to remove the "wifi" related code, and adapt it to their own widget requirements. It might be perfect for you to look at, and relatively simple to add a single button to it.


Lock-screen / Keyguard Widget

There are 2 changes to make it work as a lock-screen widget:

  • updating the widgetCategory to include keyguard
  • adding an initialKeyguardLayout

These changes are done in the ./res/xml/widget_info.xml file, as seen below:

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:initialKeyguardLayout="@layout/widget"
android:initialLayout="@layout/widget"
android:minHeight="40dp"
android:minWidth="250dp"
android:updatePeriodMillis="0"
android:widgetCategory="home_screen|keyguard" >
</appwidget-provider>

I do not know if it is possible to integrate the camera into your own lock-screen widget. Clicking on a lock-screen widget normally requires the user to unlock the device before the click works.



Related Topics



Leave a reply



Submit