Connection Refused for Android Device Web Service SYMFONY 3 -


connect android device web service on local host

following previous thread , im able connect android device local host using wamp

but still cannot connect symfony server , api datas

i sarted symfony's internal server : "server running on http://127.0.0.1:8000"

i used internet permission on androidmanifest.xml

<uses-permission android:name="android.permission.write_external_storage"></uses-permission> <uses-permission android:name="android.permission.read_external_storage"/> <uses-permission android:name="android.permission.internet"></uses-permission> <uses-permission android:name="android.permission.access_network_state"></uses-permission> <uses-permission android:name="android.permission.read_phone_state"></uses-permission> <uses-permission android:name="android.permission.download_without_notification" /> 

my mainactivity.java code

package com.example.cbmedandroid; import java.io.ioexception; import java.io.inputstream; import org.apache.http.httpentity; import org.apache.http.httpresponse; import org.apache.http.client.httpclient; import org.apache.http.client.methods.httpget; import org.apache.http.impl.client.defaulthttpclient; import org.apache.http.protocol.basichttpcontext; import org.apache.http.protocol.httpcontext; import android.app.activity; import android.os.asynctask; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; public class mainactivity extends activity implements onclicklistener {     @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         findviewbyid(r.id.my_button).setonclicklistener(this);     }      @override     public void onclick(view arg0) {         button b = (button)findviewbyid(r.id.my_button);         b.setclickable(false);         new longrunninggetio().execute();     }      private class longrunninggetio extends asynctask <void, void, string> {         protected string getasciicontentfromentity(httpentity entity) throws    illegalstateexception, ioexception {             inputstream in = entity.getcontent();             stringbuffer out = new stringbuffer();             int n = 1;             while (n>0) {                 byte[] b = new byte[4096];                 n =  in.read(b);                 if (n>0) out.append(new string(b, 0, n));             }             return out.tostring();         }          @override         protected string doinbackground(void... params) {             httpclient httpclient = new defaulthttpclient();             httpcontext localcontext = new basichttpcontext();             httpget httpget = new httpget("http://192.168.43.13:8000/api/horaire.json");             string text = null;             try {                 httpresponse response = httpclient.execute(httpget, localcontext);                 httpentity entity = response.getentity();                 text = getasciicontentfromentity(entity);             } catch (exception e) {                 return e.getlocalizedmessage();             }             return text;         }          protected void onpostexecute(string results) {             if (results!=null) {                 edittext et = (edittext)findviewbyid(r.id.my_edit);                 et.settext(results);             }             button b = (button)findviewbyid(r.id.my_button);             b.setclickable(true);         }     } } 

when launch application , click button . load during 40 sec , "connection http://192.168.43.13:8000 refused"

192.168.43.13 pc adress

what should fix . thanks.

finally! have found solution problem

when running built-in php server . need specify command

php bin/console server:run 0.0.0.0:8000 

(8000 port , can put yours)

so device or host (ip) access

if put 127.0.0.1 localhost allowed

that's why couldn't api connected localhost via wifi hotspot

it's ok now