语言

Menu
Sites
Language
How to enable http request / internet acces on samsung gear s2

I'm sending out http request on a toggle press on a web application for the gear s2 (javascript):

( function () {

    var led001Button = document.getElementById("Led001"),
        led002Button = document.getElementById("Led002");   

    function httpReq(theUrl){
        var xmlhttp = null;
        xmlhttp = new XMLHttpRequest();
//      xmlhttp.onreadystatechange = function(){
//      if (xmlhttp.readyState == xmlhttp.DONE){
//      alert(xmlhttp.responseText);
//      }
//      else{
//      alert(xmlhttp.statusText);
//      }
//      };
//      xmlhttp.onerror = function(e){
//      alert("onerror: " + xmlhttp.statusText);
//      };
        xmlhttp.open("GET", theUrl);
        xmlhttp.send();
    }

    function checkToggle(name){
            //make box2 = box1 when checked              
               var checkbox = document.getElementById(name);
               if (checkbox.checked === true){
                   httpReq('http://MYURL/WebServer/edit.php?name='+name+'&value=1');
//                console.log("set "+name+" ON");
               }else{
                   httpReq('http://MYURL/WebServer/edit.php?name='+name+'&value=0');
//                 console.log("set "+name+" OFF");
               }
    }           
    if (led001Button) {
        led001Button.addEventListener("change", function(){
               checkToggle("Led001");
        });
    }
    if (led002Button) {
        console.log('test');
        led002Button.addEventListener("change", function(){
               checkToggle("Led002");
        });
    }
} () );

When i emulate this on the gear s2 web emulator this works perfectly.

But when i install this on the gear s2 itself my webserver does not receive any requests. I gave my app Internet privilege and acces to my webserver in the config.xml file:

<access origin="MYURL" subdomains="true"></access>
 <tizen:privilege name="tizen.org/privilege/internet"/>    

but no succes. Can anybody tell me what i'm forgetting? Thanks!

 

PS had to edit some external links because they are not permitted

响应

4 回复
Gary Anderson

You absolutely can access the internet directly if you use bluetooth model of the Gear S2 Watch when it is connected to Wifi.

For a Tizen Web Application Project, you may use XMLHttpRequest. Please see the below sample project that utilizes this.

https://developer.tizen.org/development/sample/web-application/general/news-feed

Be sure to add the below snippet to the config.xml. This will allow any endpoint or api to be accessed, but for production you may want to whitelist the origin. Note that the app will work in the emulator, but not on the watch if access origin is not modified to cover your custom apis.

    <access origin="*" subdomains="true"></access>

For a Tizen Native Application Project, you may use Curl. Please see the below sample project that utilizes curl. Although this is a mobile example, it will still load on and funciton on your Gear 2 watch.

https://developer.tizen.org/development/browse-samples/native/Network/(Tutorial)_Curl

AVSukhov

Hello,

Try to use access origin="*"

and try to disable bluetooth.

Marco Buettner

you can check if you online with navigator.onLine ;>

Ivan Ramanenka

You need to check you phone and allow 'Blouetooth tethering' in Access Point Settings.

Tested on Gear S3 connected over bluetooth to my Nexus 5x (WiFi off)