How to Manage Screen On/Off Functionality: Difference between revisions

From wizarPOS
(Created page with "== Screen on/off == Here is the snippet code: <syntaxhighlight lang="java"> private void goToLockNow() { try { boolean result = systemExtApi.setDeviceOwner...")
 
(Replaced content with "{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/firmware/manage-screen-on-off}}")
Tag: Replaced
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
== Screen on/off ==
{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/firmware/manage-screen-on-off}}
Here is the snippet code:
<syntaxhighlight lang="java">
private void goToLockNow() {
        try {
            boolean result = systemExtApi.setDeviceOwner(this.getPackageName(),LockReceiver.class.getName());
            if(result){
                DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
                devicePolicyManager.lockNow();
                SystemClock.sleep(2000);
                mWakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP
                        | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass().getName());
                wakeUp();
            }
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
 
    /**
    * Wake up screen
    */
    private void wakeUp() {
        mWakeLock.acquire();
        if (mWakeLock.isHeld()) {
            mWakeLock.release();
        }
    }
</syntaxhighlight>
== Download ==
[http://ftp.wizarpos.com/advanceSDK/ScreenUpAndOff.zip Demo download]

Latest revision as of 08:47, 7 April 2024

Please visit new link of same subject:

https://smartpossdk.gitbook.io/cloudpossdk/faq/firmware/manage-screen-on-off

We're making a move! Our site's content is migrating to a new URL, to provide you with an enhanced browsing experience. Please update your bookmarks accordingly. Thank you for your continuous support!