如何让HTTP请求通过WiFi直接从Android Wear? [英] How to make HTTP Requests over WiFi directly from Android Wear?

查看:391
本文介绍了如何让HTTP请求通过WiFi直接从Android Wear?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能执行HTTP请求或打开上Android Wear插座?我曾经认为这是不可能的,但在 Web浏览器Android Wear 应用程序说folloing:

how can I execute HTTP requests or open a socket on Android Wear? I used to think that's impossible but the Web Browser for Android Wear app says the folloing:

[..],即使您的手机处于关闭状态,如果你有Android的一个SmartWatch的穿5.1和Wi-Fi*。

"[..] works even when your phone is off if you have a smartwatch with Android Wear 5.1 and WiFi"*.

我测试了它,当配对的电话已关机的应用程序可以连接互联网。

I tested it and that app CAN connect the internet when the paired phone is powered off.

每当我打开一个套接字或尝试在Android Wear HTTP请求,我总是得到一个的ConnectException 无法连接到http://foo.com (类似的堆栈跟踪<一href="http://stackoverflow.com/questions/29087298/connection-refused-in-wearablelistenerservice-android-wear-when-phone-in-sleep">here).所以我做的事情不同,那么该应用程序在做什么,我想知道那是什么。

Whenever I open a socket or try HTTP requests on Android Wear I always get a ConnectException saying failed to connect to http://foo.com (similar stack trace here). So I'm doing something different then that app is doing and I'd like to understand what that is.

背景:我的工作证明的概念,只是想能够执行HTTP请求和开放套接字。我很想知道,如果有任何的方式来做到这一点。即使包括生根手表,做一些亚洲开发银行的魔力。

Context: I'm working on proof-of-concept and just want to be able to execute HTTP requests and open sockets. I'd love to know if there's any way to do that. Even if it includes rooting the watch and doing some adb magic.

澄清:我了解的数据层API,我还是希望能够只是做HTTP请求和开放套接字。

To clarify: I know about the Data Layer API and i'd still like to be able to just do HTTP requests and open sockets.

推荐答案

如果您的手表有WIFI和它设置正确,那么你可以让你的手表时,你的手表是从手机断开网络电话;当你通过BT连接到手机,无线将被禁用。虽然它被启用,你应该能够把它看成一个通常的网络连接并进行网络通话。但请记住,如果你编写一个应用程序依赖于这一点,你的应用程序将无法所以你需要处理这种情况,并为您的应用程序,以获得相同的数据的替代工作,当它被连接到电话(即使用手机的连接)。

If your watch has Wifi and it is set up correctly, then you can make network calls on your watch when your watch is disconnected from the phone; when you connect to your phone via BT, wifi will be disabled. While it is enabled, you should be able to treat that as a usual network connectivity and make network calls. But keep in mind that if you write an app that relies on this, your app will fail to work when it gets connected to a phone so you need to handle that case and provide an alternative for your app to get the same data (i.e. using the phone's connectivity).

这篇关于如何让HTTP请求通过WiFi直接从Android Wear?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆