Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search

Adding the Lock Screen

The lock screen is a vital part of SmartDeviceLink as the lock screen prevents the user from using your application while the vehicle is in motion. SDL takes care of the lock screen for you. It still allows you to use your own activity if you prefer your own look, but still want the recommended logic that SDL provides for free.

Configure the Lock Screen Activity

You must declare the SDLLockScreenActivity in your manifest. To do so, simply add the following to your app's AndroidManifest.xml if you have not already done so:

<activity android:name="com.smartdevicelink.managers.lockscreen.SDLLockScreenActivity"

This manifest entry must be added for the lock screen feature to work.

Using the Provided Lock Screen

If you have implemented the SdlManager and have defined the SDLLockScreenActivity in your manifest but have not defined any lock screen configuration, you are already have a working default configuration.
Generic Lock Screen

Customizing the Default Lock Screen

If you would like to use the provided lock screen but would like to add your own appearance to it, we provide that as well. LockScreenConfig allows you to customize the background color as well as your app's icon. If the app icon is not included, we will use the SDL logo.

Custom Background Color

lockScreenConfig.setBackgroundColor(resourceColor); // For example, R.color.black

Custom App Icon

lockScreenConfig.setAppIcon(appIconInt); // For example, R.drawable.lockscreen icon

This sets whether or not to show the connected device's logo on the default lock screen. The logo will come from the connected hardware if set by the manufacturer. When using a custom view, the custom layout will have to handle the logic to display the device logo. The default setting is false, but some OEM partners may require it.
In your LockScreenConfig object, you can set the boolean of whether or not you want the device logo shown, if available:


Create Your Own Lock Screen

If you would like to use your own lock screen instead of the provided SDL one, but still use the logic we provide, you can use a new initializer within LockScreenConfig:


Disabling the Lock Screen Manager

Please note that a lock screen will be required by most OEMs. You can disable the lock screen manager, but you will then be required to implement your own logic for showing and hiding the lock screen. This is not recommended as the LockScreenConfig adheres to most OEM lock screen requirements. However, if you must create a lock screen manager from scratch, the library's lock screen manager can be disabled via the LockScreenConfig as follows:

View on GitHub.com
Previous Section Next Section