如何在Android应用程序中嵌入Http服务器(如i-Jetty,Paw等) [英] How to embed an Http server (like i-Jetty, Paw, etc) in android application

查看:297
本文介绍了如何在Android应用程序中嵌入Http服务器(如i-Jetty,Paw等)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的Android应用程序中集成HTTP服务器(如iJetty,Paw等)?我在互联网上找不到任何有用的教程.大多数网站(包括官方网站)仅提供服务器规范和可下载的服务器jar文件.我一直在寻找一些Java代码来将该文件集成到Eclipse项目中,以便可以将其用作应用程序中的服务器组件.有什么帮助吗?

How can I integrate an HTTP server (like iJetty, Paw, etc) in my Android application? I can't find any useful tutorial on the Internet. Most of the websites (including the official ones) just provide the server specification and downloadable server jar files. I was looking for some Java code to integrate that file in my Eclipse project so that it could be used as server component in my application. Any help please?

推荐答案

以下是我已成功使用的一个:

Here's one I have successfully used:

NanoHttpd

  • https://github.com/NanoHttpd/nanohttpd
  • http://en.wikipedia.org/wiki/NanoHTTPD

NanoHttpd是一款开放源代码的小型Web服务器,适用于以Java编程语言编写的嵌入在应用程序中的服务器.源代码由单个.java文件组成.

NanoHttpd is an open-source, small-footprint web server that is suitable for embedding in applications, written in the Java programming language. The source code consists of a single .java file.

这是一个使用它的Android示例项目:

And here is an Android sample project that uses it:

https://gist.github.com/komamitsu/1893396

它很小,很简单,使用纯Java语言编写,但是可以相当修改.还有其他一些,但它们的重量更重一些.取决于您要做什么.我建议您从小处着手,看看是否适合您的目的.

It's very small and simple and in pure java but it is fairly modifiable. There are others but they are a bit more heavyweight. Depends what you want to do. I would recommend you start small and see if that suits your purposes.

这篇关于如何在Android应用程序中嵌入Http服务器(如i-Jetty,Paw等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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