Languages

Menu
Sites
Language
Kiosk mode

Hello,
I wonder if you can tell me how to turn a Tizen Web App into Kiosk Mode, so the the app can't be closed or the phone can't get shutdown without a Admin password. I have to make an app that is publicily used by users in a museum and have to use a Gear S2 due to its NFC feature.

Last year I made a similar app in Android Wear and there it was relativley easy to achieve the functionality of a Kiosk Mode.

After some research I managed to disable the back button and the return to the app after screen off with this code:

  $(window).on("tizenhwkey", function(e) {
      if (e.originalEvent.keyName === "back") {
          $("#text").text("Back pressed!");
          e.originalEvent.stopPropagation();
          e.originalEvent.preventDefault();
      }
  });

  tizen.power.request("SCREEN", "SCREEN_NORMAL");
  tizen.power.setScreenStateChangeListener(function(previousState, changedState) {
      if (currState === 'SCREEN_NORMAL' && prevState === 'SCREEN_OFF') {
          var app = tizen.application.getCurrentApplication();
          tizen.application.launch(app.appInfo.id, function() {});
      }
  });

But the menu/more button is still working. The user shouldn't be able to leave the app. Only admins should be able to do that.

Responses

5 Replies
Marco Buettner
Add :)
if (e.originalEvent.keyName === "menu") {
          $("#text").text("Back pressed!");
          e.originalEvent.stopPropagation();
          e.originalEvent.preventDefault();
      }
J. Schwartz

I already tried it. But the event is not fired so the watch goes directly to the menu screen.

Marco Buettner

A on watch... I overread it... Yeah... menu key isnt defined in the wearable environment ... so it will not fired/supported yes.. I think with the methods of the Tizen Studio/known APIs it will not be able... 

Maybe you can watch in KNOX and native application world?

https://seap.samsung.com/sdk/knox-tizen-wearables

Onur Şahin

I did not try this but you might use visibilitychange event to re-lauch the app. Something like this;

    function visibilityChange() {
        if (document.hidden || document.webkitHidden) {
            //launch directly
            tizen.application.launch('YOUR_APP_ID');
            
            //lauch with alarm
            var date = new Date();  
            date.setSeconds(date.getSeconds() + 1, 0);
            var alarm = new tizen.AlarmAbsolute(date);
            tizen.alarm.add(alarm, 'YOUR_APP_ID');
        }
    }

    document.addEventListener("visibilitychange", visibilityChange);
    document.addEventListener("webkitvisibilitychange", visibilityChange);

 

Not sure if lauching itself directly works so I added lauching with alarm too to the code just in case.

J. Schwartz

This is a very good compromise solution. I don't know if I would have come to this solution myself in the near time.

The screen changes for a moment to the clock face, but I can't leave the app. The only thing what is not so good is that I can shutdown the watch by holding the menu key but it seems I have to live with it.

It would be great if anyone has a better solution. This is already a vergy approach.

P.S. It works better without the alarm.