Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 527
KhanZeeshan Avatar asked Aug 28 '11 19:08

KhanZeeshan


People also ask

Can you host a server on a mobile device?

If the website is relatively basic, you can use your Android device as a host and save money on powering an expensive server. Similarly, you can retake the space used by a server or a computer running as a web server. Perhaps you can use the server for a different purpose.


2 Answers

There is one problem with your setup and mobile devices: mobile networks (wifi and 3g) mostly use NAT, which prevents inbound connections. This makes mobile devices inaccessible from the internet (inbound) while they can still initiate outbound connections. For this reason mobile devices mostly do not host servers.

like image 54
Peter Knego Avatar answered Oct 14 '22 05:10

Peter Knego


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.

like image 34
Husyn Avatar answered Oct 14 '22 05:10

Husyn