I'm trying to block the screen with the following code:
protected void onBloquear(View view) {
DevicePolicyManager mDPM = null;
mDPM.lockNow();
}
Source: link
But it gives the following error.
Caused by: java.lang.NullPointerException:
Attempt to invoke virtual method 'void android.app.admin.DevicePolicyManager.lockNow()'
on a null object reference
Does anyone have an idea what it can be?