webserver - Android embedded web-server -
i want embed web-server in android application devices connecting have 2 abilities. 1 send xml-file can parse , stuff , other able download file sd-card.
i found nanohttpd , androidhttpd etc not documentation , i'm facing problems on how give ability download file. there tutorial/example handles files or easy-to-use library except of ones noted above?
two things come mind, both permissions related. take @ android manifest, you'll want 2 permissions app
<uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.write_external_storage" />
internet, because you're accessing network services, , write_external_storage because when nanohttpd receives incoming connection writes temp files , / phones map "java.io.tmpdir" point @ sd card.
create class extends basic nanohttpd, passing socket want run on, , implement abstract 'serve()' method.
when client application uploads xml file, sure it's sending in standard multipart form encoding, , filename given in "files" map parameter serve().
when send response client, new response() object, , can either hand inputstream (from sd card file) or string content.
if need documentation, in form of examples, nanohttpd includes functional webserver serves files, , call "demoserver" great debugging client applications send. there arent android specific examples yet volume of questions suggests ought add some. :)
thanks. hope helps. let me know if have more questions.
Comments
Post a Comment