Stack Exchange
Whats wrong with this java method ? I'm getting errors on the start
I'm getting errors
Invalid method declaration, return type required
Missing method body
private void AutomaticServerConnect()
{
    new Thread(new Runnable() {
        public void run() {
            response = Get(HttpCommandToSend(iptouse, 8098, "nothing"));
            text = (TextView) findViewById(R.id.textView2);
            if (response != null)
            {
                try
                {
                    final String a = new String(response, "UTF-8");
                    text.post(new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            text.setText(a + " On \n" + ipaddresses[counter]);
                            status1.setText("Connected");
                            String successconnected = null;
                            successconnected = "Successfully connected";
                            textforthespeacch = successconnected;
                            MainActivity.this.initTTS();
                        }
                    });
                    iptouse = ipaddresses[i].substring(0, ipaddresses[i].lastIndexOf("=") + 1);
                    connectedtoipsuccess = true;
                    connectedSuccess = true;
                    Logger.getLogger("MainActivity(inside thread)").info(a);
                    if (!iptouse.isEmpty())
                    {

                    }
                } catch (UnsupportedEncodingException e)
                {
                    e.printStackTrace();
                    Logger.getLogger("MainActivity(inside thread)").info("encoding exception");
                }    

                Logger.getLogger("MainActivity(inside thread)").info("test1");
            }
            else
            {
                text.post(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        text.setText("Connection Failed");
                        status1.setText("Connection Failed");
                        String successconnected = null;
                        successconnected = "connection failed";
                        textforthespeacch = successconnected;
                        MainActivity.this.initTTS();
                    }
                });
            }                
        }).start();
    });

I'm getting error on the line:
}).start();


Invalid method declaration, return type required
  Missing method body

And also an error on the line
});


} expected


Due to the volatility of all the curly braces involved, if someone sees an indentation oversight in my edit, by all means, please fix it.

Proper indentation will help you find the invalid braces :
private void AutomaticServerConnect()
{
    new Thread(new Runnable() {
        public void run() {
            ...
        }).start();
});

you closed the run method, but not the anonymous Runnable instance.
It should be :
private void AutomaticServerConnect()
{
    new Thread(new Runnable() {
        public void run() {
            ...
        } // added }
    }).start();
} // removed );


Count your curly braces.  You are missing a close brace somewhere.
