Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SendServer extends AsyncTask<String, Void, Void> {
- @TargetApi(Build.VERSION_CODES.CUPCAKE)
- protected void onPreExecute() {
- super.onPreExecute();
- //GPSTracker gps = new GPSTracker();
- //if(gps.canGetLocation()){}
- //tvInfo.setText("Полез на крышу");
- }
- protected Void doInBackground(String... params) {
- try {
- //System.out.println("params 0 : "+params[0]);
- HttpPost httpost = new HttpPost("http://i.enot-pomi4nuk.com.ua/appgps/send.php?text="+params[0]);
- DefaultHttpClient httpclient = new DefaultHttpClient();
- List <NameValuePair> nvps = new ArrayList <NameValuePair>();
- httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
- ResponseHandler<String> responseHandler = new BasicResponseHandler();
- httpclient.execute(httpost, responseHandler);
- TimeUnit.SECONDS.sleep(15);
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- System.out.println("UnsupportedEncodingException");
- e.printStackTrace();
- } catch (ClientProtocolException e) {
- // TODO Auto-generated catch block
- System.out.println("ClientProtocolException");
- e.printStackTrace();
- } catch (IOException e) {
- System.out.println("IOException");
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
- }
- SendServer cattask = new SendServer();
- cattask.execute("test");
- static String test="ok";
- SendServer cattask = new SendServer();
- cattask.execute(test);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement