Answer the question
In order to leave comments, you need to log in
How to organize a GET request in Android Studio after switching to ESP 8266?
The bottom line is that I am new to java and programming in general.
I barely put together a program to control the TV via arduino + bluetooth (that is, on the tablet, by pressing the buttons in the program, the bluetooth code is sent to the arduino).
Now I switched from bluetooth to wifi ESP 8266, everything is the same there, except for what is needed by pressing the button in the program, a get request was sent to 192.168 .
Here is a piece of how it was
onoff.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onoffdo();
clickEventSlide();
}
});
private void onoffdo() {
if (btSocket != null) {
try {
btSocket.getOutputStream().write("1".toString().getBytes());
} catch (IOException e) {
}
;
}
}
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("http://192.168.1.102/uartpro?speed=19200&send=32");
try {
Log.d(Tag, "запрос отправлен");
HttpResponse response = httpclient.execute(httpget);
HttpEntity httpEntity =response.getEntity();
String line = EntityUtils.toString(httpEntity, "UTF-8");
Log.d(Tag, line);
}
catch (ClientProtocolException e) {
Log.d(Tag, "ошибочка");
}
catch (IOException e) {
// TODO Auto-generated catch block
Log.d(Tag, "запрос не отправлен");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question