class Upload extends AsyncTask { protected Boolean doInBackground(Integer... params) { try { URL url = new URL("http://stuff.raptilic.us/phonestatus/?output=none&battery-level=" + params[0] + "&charging-state=" + params[1]); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setReadTimeout(10000); con.setConnectTimeout(15000); con.setRequestMethod("GET"); con.setDoInput(true); con.connect(); InputStream in = con.getInputStream(); ByteArrayBuffer down = new ByteArrayBuffer(1024); int i; while((i = in.read()) != -1) { down.append(i); } String result = new String(down.toByteArray()); if(result.equalsIgnoreCase("OK")) { return true; } } catch (Exception e) { } return false; } protected void onPostExecute(Boolean result) { if(result) MainActivity.showToast("Status uploaded"); else MainActivity.showToast("Failed to upload status"); } }