After using SCREEN_ON SCREEN_OFF broadcast receiver, screen does not seem to switch off automatically as it used to for default android app.
None of the code commented below works for Android 4.4.2 (API 19 onward)
int time = android.provider.Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, Integer.MAX_VALUE);
// Toast.makeText(context, "Screen Time out is "+new Date(lastTimeScreenOn+15000) + ", lastTimeScreenOn = "+new Date(lastTimeScreenOn), Toast.LENGTH_SHORT).show();
// screen off if more than 15 sec
if(System.currentTimeMillis() - lastTimeScreenOn > 15000)
{
Toast.makeText(context, "Screen Time out ", Toast.LENGTH_LONG).show();
//DevicePolicyManager mDPM = (DevicePolicyManager)context.getSystemService(Context.DEVICE_POLICY_SERVICE);
//mDPM.lockNow();
//Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 1000);
}