REST web service calls from android device - java

I made an android application which connects to a local web service on my desktop computer, in a network with a router.
In AVD, I managed to make calls to the web service, but I have problems when I deploy the application on my android device (connection timeout). The phone was connected to the same network, but the call does not work.
Is there a simple way to make calls to the web service from the device? What are the ways to do this?

make sure that the url you are trying to reach is reachable. For example your computer may be behind a firewall which is not allowed to be accessed from outside the network. You can connect your phone to wireless access point on the same network as your computer.
or you can place the web service on a server that is web accessible.

Related

which IP address should I make in the Post method?

I made an API between an android application and a desktop application (java). I test that in local between android studio device and my desktop application and it works with local address:
post("http://10.0.2.2:8080/api/v1/locations", json)
but now I want to install the app in my phone so I'm not in local anymore, I want to know which address should I make to post from my phone to my laptop java application?
You need to deploy your service that you have created on some server then you can access same.
so the IP you need to use of server.

How to use firebase library without a VPN app in android

I made android app that uses firebase, but as the users live in Syria they should use a VPN to use my app because firebase is blocked in that country.
Is it possible to use a script or a JSON file in my app to workaround this problem?
You should try setting up your own vpn connection inside the app you're developing.
Try using this source to ease out your work.
another solution is that at runtime when your app attempts to connect with internet you can programatically reroute it's root default base connection route to your preferred IP address thus eventually solving your problem without using any external app.
Lastly,You can't try creating a service which will be installed in the backend and when the app is launched the service is automatically triggered with it and hence it will automatically route your connection to preferred vpn IP address.

Android apps calling web service design logic

I has an android apps install in my galaxy tab. This apps will call a web service in the web server which locate in the office. The web service then will call to database in another server. The web server and database server is in same LAN. My web server IP is dynamic which will change every time the modem is restarted and I do not register any domain name. How I can configure my router/modem to let the apps can call the web services which the ip is not statics? Is it possible? Please help.
What is OS of your webserver running ? Windows or Linux? You should configure a static IP for your webserver machine. This way webserver IP 'll not change after modem is restarted. You may find this in Google search

Communicate Multiple Emulators

I want to make an http server on one android application and get its contents from another emulator.
Also other than http protocol, is there any other networking API + sample code that someone give me to connect and get content from one emulator to another?
Emulator is behind a virtual router. To make it accessible to the outside world (including other emulators) you need to configure Network Redirections (basically port forwarding)

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.
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.
The problem you're going to run into here are:
Android devices are mobile. They do not have a fixed IP address or DNS address. You'd need to implement some sort of discovery service.
Android devices move between networks, and some networks will have 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. Once the notification arrives, have your application contact a web server at a known address to see what the request actually is.
In other words, you'd be running an intermediary web server that proxies requests on behalf of your Android device.
More information about C2DM can be found here:
http://code.google.com/android/c2dm/

Categories