简体   繁体   中英

Tizen gear 2 web request

I would like to make a web request from tizen gear 2 with javascript. My code is:

    var url = "https://..."
    var client = new XMLHttpRequest();

    client.open("POST", url, true);
    client.setRequestHeader("Accept-Language", 'en-us');
    client.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    client.setRequestHeader("Connection", "close");
    client.send('data=2000');
    client.onreadystatechange = function() { alert(client.responseText); };

When I run the application on gear(connected through bluetooth at mobile), no web request is send to my website. I have already set in my config.xml <access origin="*" subdomains="true"></access> Can you please help me with this problem?

Gear 2 cannot directly send web requests.

The only workaround I know of is development of a custom Samsung Accessory service (using Accessory SDK) that will send requests on behalf of Gear. Then you will need to integrate it with your Gear app.

Cannot share any code though, and AFAIK there's not such sample in Accessory SDK ;(

BTW: Gear S have 3G and WiFi interfaces, so this code should work if any of those is available (permissions/privileges apply though, including the "access origin" one you mention in your question).

Gear 2没有SIM卡功能或WIFI,因此唯一的方法是制作配套应用,并请求主机应用使用该API,然后获得响应并将其发送给Gear。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM