简体   繁体   English

Android应用程序的HTTP接口

[英]HTTP interface for Android application

Hi: I want to implement a http remote control for an Android application: From a browser on a computer in the local area network the application running on the Android device should be controlled. 嗨:我想为Android应用程序实现http远程控制:应该从局域网中计算机上的浏览器控制Android设备上运行的应用程序。

Are there any recommendation how to implement this? 有什么建议如何实现这一点? I heard about i-jetty but it is not uncomplex to integrate it into an existing app. 我听说过i-jetty,但将其集成到现有应用程序中并不复杂。

The problem you're going to run into here are: 您将在这里遇到的问题是:

  1. Android devices are mobile. Android设备是移动设备。 They do not have a fixed IP address or DNS address. 它们没有固定的IP地址或DNS地址。 You'd need to implement some sort of discovery service. 您需要实现某种发现服务。

  2. Android devices move between networks, and some networks will have NAT. Android设备在网络之间移动,并且某些网络将具有NAT。 You won't always be able to contact the device. 您将无法始终联系该设备。

My advice here would be to use the new Android C2DM service and push a command down to the device telling your application that there's a request waiting. 我的建议是使用新的Android C2DM服务并将命令下推到设备,告诉您的应用程序正在等待请求。 Once the notification arrives, have your application contact a web server at a known address to see what the request actually is. 通知到达后,让您的应用程序与已知地址的Web服务器联系,以查看请求的实际含义。

In other words, you'd be running an intermediary web server that proxies requests on behalf of your Android device. 换句话说,您将运行一个代表您的Android设备代理请求的中间网络服务器。

More information about C2DM can be found here: 有关C2DM的更多信息,请参见:

http://code.google.com/android/c2dm/ http://code.google.com/android/c2dm/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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