I want to send data to the local server (PHP) from the Android application but it does not work This is my code Work with remote server):
string path = "http: //localhost/sd.php"; HTTP Client Client = New DefaultHttpClient (); HTTP Connection Perms.Setection Timeout (Client.JetPrems (), 100000); HTTP response response; JSONObject json = new JSONObject (); {HTTP post post = try new HTTP post (path); Json.put ("im", 999); Json.put ("cTime", 12); Logs. I ("Jason object", json.toString ()); Post.setHeader ("Jason", json.toString ()); = New String Entity from StringType (json.toString ()); Se.setContentEncoding (new Basic Header (HTTP.CONTENT_TYPE, "Application / Jason")); Post.setEntity (se); Feedback = client.execute (post); } Hold (exception e) {object n = e.getStackTrace (); Toast. Make text (getApplicationContext (), n.toString (), toast .LENGTH_SHORT). Show (); } address http: //localhost/sd.php I'm wrong about pleas help me find a solution to this problem
You need the server's IP address. The app is the local host phone
Comments
Post a Comment