语言

Menu
Sites
Language
gyroscope in wearable emulator

Hi everyone,

I'm developing an app for wearable devices and I need gyroscope information.

This is my code:

if (window.DeviceOrientationEvent) {
          document.getElementById("title").innerHTML = "DeviceOrientation";
		  window.addEventListener('deviceorientation', function(eventData) {
		    document.getElementById("title").innerHTML = eventData.gamma+' '+eventData.beta+' '+eventData.alpha;
		  }, false);
		} else {
		  document.getElementById("title").innerHTML = "Not supported."
		}

The event is supported as the title is set to "DeviceOrientation", the problem is that the event is never launched.

I tried rotating the emulator but nothing happens. I wanted t inject the event from the event injector interface but apparently it is not supported in the wearable sdk.

How can I have the rotation event launched? any idea?

Thanks!

Stefano

响应

7 回复
Marco Buettner

Read Documentation... DeviceOrientation isn't support by wearables yet

Stefano Bennati

Thanks for the answer.

Can you please point me to the documentation you are referring to? What should I use instead?

Best,

Stefano

AVSukhov

Hello,

Try to use "SystemInfoDeviceOrientation" in SystemInfo API.

Stefano Bennati

Thanks a lot for the information!

Now I tried your suggestion and read the system-information API guide.

I added the following privileges:

<tizen:privilege name="http://tizen.org/privilege/application.launch"/>
<tizen:privilege name="http://tizen.org/api/system"/>
<tizen:privilege name="http://tizen.org/api/setting"/>
<tizen:privilege name="http://tizen.org/privilege/system"/>

I added the last privilege as the two specified in the guide are not existing in the API and that is the one that looks most similar.

I'm running this code:

var deviceCapabilities;
deviceCapabilities = tizen.systeminfo.getCapabilities();
if (deviceCapabilities.wifi)
{
   console.log("wifi is available");
}

 In the js console I get this error: Uncaught ReferenceError: tizen is not defined

Do you know what I'm doing wrong?

Thanks!

Stefano Bennati

Ok I figured that out: "tizen" is not defined in the simulator, while it works in the emulator.

To be more precise, it does not work wery well. http://imgur.com/vPtAO5t It doesn't matter the emulator's orientation, the output will always be portrait_primary.

So how can I change the orientation of the emulator?

Thanks!

Marco Buettner

You have a simulator on Tizen SDK for Wearables? Crazy, I only have Emulator options o0

Stefano Bennati

Yes, if you click on the preview button (it is explained in the first video) Chrome will open and show you the app