A
A
AISka12015-06-25 17:49:52
Android
AISka1, 2015-06-25 17:49:52

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) {
            }
            ;
        }
    }

now tried this way by inserting it into void onoffdo()
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

1 answer(s)
S
Soprano61, 2015-10-02
@Soprano61

Hello, please contact me via Skype Soprano6111 or mail [email protected] there is a question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question