I\'m trying to connect to a REST-Server (which I created with Spark) via Android. I can send POST-Requests with POSTMAN (Chrome Addon) and get what I want, but when I try to
Android emulator uses 10.0.2.2 as a host loopback interface. Use it instead of 127.0.0.1 which is emulator itself.
127.0.0.1 is the loopback ip address on your android device. You need the ip address of your computer. I presume you 're running on an emulator or Android device of some sort. If your server is running on a local Wifi network, use the IP address of your Wifi adapter then replace 127.0.0.1 with that address.
TLDR; Use you server's IP address instead of 127.0.0.1
Linux: ifconfig [wlan0]
Windows: ipconfig
Edit 2020:
On newer versions on Android, all HTTP traffic must be encrypted, otherwise the android framework will throw an error. Therefore it's advisable to use a tunnelling server like Ngrok - which comes with free SSL - when testing on your local server.
Check your xammp or wamp connection. if the mysql and apache services are not active then start all services and run your application it gave proper output
if your test on local, try to check an ip address (on window open cmd run ipconfig)
then put your ip address again.
This's an example
String url = http://127.0.0.1:8080/user <-- error
String url = "http://172.16.5.240:8080/user <-- worked