Domanda

I'm trying to create a web-application using Tizen SDK. When I launch the app everything is fine but when I press a "Back" button on emulator nothing happens and I see a message:

55435/js/main.js:9:ReferenceError: Can't find variable: tizen

I looked at main.js and there's a code:

//Initialize function
var init = function () {
    // TODO:: Do your initialization job
    console.log("init() called");

    // add eventListener for tizenhwkey
    document.addEventListener('tizenhwkey', function(e) {
        if(e.keyName == "back") {
            tizen.application.getCurrentApplication().exit(); // HERE IS THE ERROR
        }
    });
};
$(document).bind('pageinit', init);

A simple alert(window.tizen) said that it is undefined so I thought that some js file wasn't attached to project. Here are scripts that was generated by Tizen SDK:

<script src="tizen-web-ui-fw/latest/js/jquery.js"></script>
<script src="tizen-web-ui-fw/latest/js/tizen-web-ui-fw-libs.js"></script>
<script src="tizen-web-ui-fw/latest/js/tizen-web-ui-fw.js" data-framework-theme="tizen-white"></script>
<script type="text/javascript" src="./js/main.js"></script>

I think some script should be added but I don't know which one.

È stato utile?

Soluzione 2

I don't know how it is working now, but I found the solution. I just changed the workspace and it worked.

Altri suggerimenti

The 'tizen' namespace seems to disappear on anything but the files directly in the .wgt. So if it's loading a webpage from somewhere else, the 'tizen' just goes away.

A workaround that might work for you, is having a .js/.html file locally within the widget that does the things you need it to do for you...and then having everything else load dynamically. In our case, we had a local .html file do tizen.registerKey for our application, and then a window.onload redirect to our hosted solution.

The tizen namespace is usually available only after the right privilege was declared in config.xml, same goes for any other of the API.

This is how you declare the privileges or you can simply add this line:

<tizen:privilege name="http://tizen.org/privilege/tizen"/>

in config.xml,

Only after the privilege is set the Tizen Web Device API is instantiated (under the window.tizen namespace).

Similarly if you want to have the API available unde window.tizen.download namespace you need to have:

<tizen:privilege name="http://tizen.org/privilege/download"/>

added in your privilege list in config.xml.

For a full list of the privileges use the IDE or check this list.

What SDK version are you trying to use? I guess, here's a solution: http://www.mail-archive.com/general@lists.tizen.org/msg00092.html

Actually , you don't need to set privilege in config.xml for using tizen.application.xx API.

Without setting any privilege ,the code tizen.application.getCurrentApplication().exit() would run normally.

It may be temporary bug at Platform. As you know , Tizen is very unstable for now since is just growing.

Just disable checkbutton "Enable Live Editing" in "Run Configurations" menu (rigth click on project -> "Run as" -> "Run configurations...")

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top