Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void reportSend(View v)
- {
- th = new Thread(new Runnable() {
- @Override
- public void run() {
- Log.i("TAG","MSG");
- HttpURLConnection connection = null;
- StringBuilder sb = new StringBuilder();
- try {
- connection = (HttpURLConnection) new URL ("http://spaces.ru").openConnection();
- connection.connect();
- if(connection.HTTP_OK == connection.getResponseCode())
- {
- BufferedReader input = new BufferedReader(new InputStreamReader( connection.getInputStream(), "cp1251"));
- String line;
- while ((line = input.readLine()) != null)
- {
- sb.append(line);
- sb.append("n");
- }
- }
- }
- catch (Exception cause) {
- cause.printStackTrace();
- // Toast.makeText(MainActivity.this, cause.getMessage().toString(), Toast.LENGTH_LONG).show();
- }
- finally {
- if(connection != null)
- connection.disconnect();
- }
- Log.i("NET", sb.toString());
- }
- });
- th.run();
- }
Add Comment
Please, Sign In to add comment