httpconnection

How do you connect localhost in the Android emulator?

落花浮王杯 提交于 2019-11-26 03:33:29
问题 I have made a php script inside localhost and I am connecting that with httpClient but I am getting a problem. Please tell me how can I connect to a php file at localhost from the emulator? 回答1: Use 10.0.2.2 to access your actual machine. As you've learned, when you use the emulator, localhost ( 127.0.0.1 ) refers to the device's own loopback service, not the one on your machine as you may expect. You can use 10.0.2.2 to access your actual machine, it is an alias set up to help in development

Sending POST data in Android

点点圈 提交于 2019-11-25 21:49:10
问题 I\'m experienced with PHP, JavaScript and a lot of other scripting languages, but I don\'t have a lot of experience with Java or Android. I\'m looking for a way to send POST data to a PHP script and display the result. 回答1: * Updated Answer which works on Android 6.0+. Thanks to @Rohit Suthar, @Tamis Bolvari and @sudhiskr for the comments. * public class CallAPI extends AsyncTask<String, String, String> { public CallAPI(){ //set context variables if required } @Override protected void