'Android - Create RESTful WebService - Host it on mobile

My question is how to create a web service on android device & host it on the mobile device.

I don't want to access an already created webservice deployed on a server; I want to create a webservice that returns json/xml & host it on mobile.

RESTful Web Services Implementations in Mobile Devices says it's doable for Java-based mobile devices, so I think it can be done for Android too.



Solution 1:[1]

What you can do is make an Android service which pings a server ( a web-server) every 30 minutes or so simply send a bit from client to server and back to check the availability of request from another phone. This way you can upload media files to server and download them to your another device.

Solution 2:[2]

I am trying to solve the same problem and I am leaning towards https://github.com/NanoHttpd/nanohttpd.

It is a tiny webserver without any REST or MVC functionality, thus you would have to write it yourself (MVC, content negotiation, etc).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Husyn
Solution 2 Franklin Dattein