Guest User

Untitled

a guest
Feb 25th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. public Runnable runnableToggle = new Runnable() {
  2. @Override
  3. public void run() {
  4. try {
  5. String url = "https://api.lifx.com/v1/lights/" + Bulb.this.ID + "/toggle/";
  6.  
  7. URL obj = null;
  8. try {
  9. obj = new URL(url);
  10. } catch (MalformedURLException e) {
  11. System.out.println("Malformed URL");
  12. e.printStackTrace();
  13. }
  14.  
  15. assert obj != null;
  16. HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
  17.  
  18. String authS = "Bearer MY_TOKEN";
  19. con.setRequestProperty("Authorization", authS);
  20. con.setRequestMethod("POST");
  21. con.setDoOutput(true);
  22.  
  23. } catch (Exception e) {
  24. e.printStackTrace();
  25. }
  26. }
  27. };
  28.  
  29. Thread t = new Thread(deskBulb.runnableToggle);
  30. t.start();
Add Comment
Please, Sign In to add comment