I\'m interested about Android and have been trying to find an example or tutorial about creating a custom lockscreen.
I wanna create new lock screen for easy accessi
Lock screen widgets were deprecated in Android 5.0 and above. To help fill the void, you can use the Adenda SDK. It extends the Android stack to let you design and program your layouts on the lock screen like you would with any other app, and feed them into the SDK.
For example:
AdendaAgent.addCustomFragmentContent (Context context, String actionToPerformOnUnlock, String your.fragment.name, Bundle fragmentArgs, String identifier, boolean bDisplayUntilCancelled)
I'm affiliated with Adenda for full disclosure
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(Source code).
As far as I know, Google hasn't released an API that allows you to change the lock-screen on un-rooted devices.
I wrote a post about How to write simple Android Lock Screen
In short, you can run a service that contains BroadcastReceiver that will listen to any event of Intent.ACTION_SCREEN_OFF
, then you can draw your custom Lock Screen on top of everything by using android.permission.SYSTEM_ALERT_WINDOW
.
If you have the native source code, this is where Google has implemented the lock screen code
androidgingerbread/frameworks/base/policy/src/com/android/internal/policy/impl/LockScreen.java
This gets built into android.policy.jar. I would say the best way to achieve what you are trying is to write a new homescreen app with required features as stated above.