I am using IP to transfer data from android to arduino, hopefully I am able to establish the connection with arduino+esp8266 wifi module by choosing its name in the wifi lists in setting since its working as access point. Also through any browser I can send data to the IP by only writing this "192.168.4.1:80?pin=13". However I have a problem with android which is the get not transmitting the request because of its not received by the arduino.
Here is my code, I have also included internet permission in android manifest. What is wrong with it?
final Button image=(Button) findViewById(R.id.button1);
image.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
image.setText("making change");
String urlGET = "http://192.168.4.1:80/?pin=13";
HttpGet getMethod = new HttpGet(urlGET);
// if you are having some headers in your URL uncomment below line
//getMethod.addHeader("Content-Type", "application/form-data");
HttpResponse response = null;
HttpClient httpClient = new DefaultHttpClient();
try {
response = httpClient.execute(getMethod);
int responseCode = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
String responseBody = null;
if (entity != null) {
responseBody = EntityUtils.toString(entity);
//here you get response returned from your server
Log.e("response = ", responseBody);
// response.getEntity().consumeContent();
}
JSONObject jsonObject = new JSONObject(responseBody);
// do whatever you want to do with your json reponse data
}
catch(Exception e)
{
e.printStackTrace();
}
}
});
}
}