Using the lockNow() function the display is turned off and then locked, but how to lock the display keeping it on? I'd like to know if exists a way to invoke the lock screen without turning the display off so the user can (eventually) unlock it without the necessity to press down the power button.
You can try to turn the screen on after the lockNow() call with something like that:
PowerManager powerManager = ((PowerManager) getSystemService(Context.POWER_SERVICE));
WakeLock screenLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag");
screenLock.acquire();
screenLock.release();
You will need to add the required permission to the manifest file:
<uses-permission android:name="android.permission.WAKE_LOCK" />