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

From wizarPOS
No edit summary
(Replaced content with "{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/firmware/manage-screen-on-off}}")
Tag: Replaced
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
== Overview ==
{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/firmware/manage-screen-on-off}}
This guide provides a code snippet to demonstrate how to manage screen on/off functionality.
== Code Snippet ==
The specific code snippet for this function will be detailed here, showcasing how to programmatically turn the screen on or off.
<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!