API Levels
Lock widgets were introduced in API 17 (4.2) and removed in API 21 (5.0). They are not supported in other official releases.
Main widget
I wrote a simple widget as a demo tutorial - it contains all the template code needed for the widget, and quite a bit:
I wrote it in such a way that every user can delete the wifi code associated with it and adapt it to their requirements for widgets. It may be ideal for you to watch, and relatively simple to add one button to it.
Keypad Lock / Lock Widget
There are two changes to make it work as a lock widget:
widgetCategory update to enable keyguard- adding
initialKeyguardLayout
These changes are made in the ./res/xml/widget_info.xml file, as shown 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 my own lock widget. Clicking on the lock screen widget usually requires the user to unlock the device before clicking.
Richard Le Mesurier
source share