Advertisement
Guest User

Untitled

a guest
May 28th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1.     protected static void postCoors(double lat, double lon, double speed)
  2.     {
  3.         try {
  4.             String url = "http://vrbrusnichka.appspot.com:80/coordinates/request";
  5.             HttpClient client = new DefaultHttpClient();
  6.             HttpPost post = new HttpPost(url);
  7.  
  8.             List<NameValuePair> pairs = new ArrayList<NameValuePair>();
  9.             pairs.add(new BasicNameValuePair("userName", MainActivity.name));
  10.             pairs.add(new BasicNameValuePair("lat", Double.toString(lat)));
  11.             pairs.add(new BasicNameValuePair("lon", Double.toString(lon)));
  12.             pairs.add(new BasicNameValuePair("velocity", Double.toString(speed)));
  13.             post.setEntity(new UrlEncodedFormEntity(pairs));
  14.  
  15.             HttpResponse response = client.execute(post);
  16.         } catch (Exception e) {System.out.println(e.getMessage());}
  17.     }
  18.  
  19.     protected static void postRegid(String regid, String name, String platform){
  20.         try {
  21.             String url = "http://vrbrusnichka.appspot.com:80/team/save";
  22.             HttpClient client = new DefaultHttpClient();
  23.             HttpPost post = new HttpPost(url);
  24.  
  25.             System.out.println("Regid: " + regid);
  26.             System.out.println("Name: " + name);
  27.             System.out.println("Platform: " + platform);
  28.            
  29.             List<NameValuePair> pairs = new ArrayList<NameValuePair>();
  30.             pairs.add(new BasicNameValuePair("userName", name));
  31.             pairs.add(new BasicNameValuePair("token", regid));
  32.             pairs.add(new BasicNameValuePair("platform", platform));
  33.             post.setEntity(new UrlEncodedFormEntity(pairs));
  34.  
  35.             HttpResponse response = client.execute(post);
  36.         } catch (Exception e) {System.out.println(e.getMessage());}
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement