Languages

Menu
Sites
Language
Gear S3 Watch resume application on leaving low power mode

I have written a stopwatch-type timer application to keep track of multiple timings when cooking.

After a few seconds of no input, the watch goes to the default always-on watchface, which is what I want it to do.

If I re-activate the watch quickly, the display re-activates with my application still running, which again is what I want it to do.

If the watch is inactive for about a minute, then re-activating it brings up the normal watch face.  When I re-start the application, it has remembered its internal state.  I am using real-time timestamps for the timer start events, so all of my timers are still running and correct.

What I want is that when I re-activate the watch after low-power mode, it resumes my application instead of the normal watch face, no matter how long I have left the watch in low-power mode.  I have not been able to find the API for this on the web.  Could someone help me please?

 

Responses

1 Replies
Armaan-Ul- Islam

You cannot change the 'Low Power' Mode/'Power Saving Mode' behavior, But what I can suggest you is to launch Home app (Which is 'watchface' in case of wearable) while the screen is off for a specific duration.

 

You need to use tizen 'Power API' and 'Application API' for that. Set a screen state change listener and launch home/watchface while the screen is off. I'm sharing a draft sample code for you, Change this according to your need.

 

function onLaunchSuccess () {
    console.log("Launched Home");}

function onLaunchError () {
    console.log("Cannot Launch Home");}

function launchWatchFace(){
	var appId ="com.samsung.w-home";        // For Samsung gear device
	var appId2 = "org.tizen.w-home";	// For Emulator
	tizen.application.launch(appId, onLaunchSuccess, onLaunchError); 
}

function onScreenStateChanged(previousState, changedState) {
    if(changedState=='SCREEN_OFF'){
    	console.log("Screen off Event");
    	launchWatchFace();
    }
}
tizen.power.setScreenStateChangeListener(onScreenStateChanged);

 

Add 'power' and 'application.launch' privileges in config.xml file. And you have to add a background-category in config.xml-> Tizen -> Background-category > + Otherwise your app won't operate while it's on background or screen is off.

 

Relevant documentations:

https://developer.tizen.org/development/guides/web-application/device-settings-and-systems/power-states

https://developer.tizen.org/community/code-snippet/web-code-snippet/launch-%E2%80%98settings%E2%80%99-app-wearable-web-application-0