Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. public void onClick(View view) {
  2. if (btnLock.getText().equals("Enabled")) {
  3. btnLock.setText("Disable");
  4. txtStatus.setText("Status: Lock");
  5.  
  6. OkHttpClient httpClient = new OkHttpClient();
  7.  
  8. String url = "magilock.epizy.com/ChangeStatus.php?lock=1";
  9. Request request = new Request.Builder()
  10. .url(url)
  11. .build();
  12.  
  13. Response response = null;
  14. try {
  15. response = httpClient.newCall(request).execute();
  16. Toast.makeText(getActivity(), response.body().toString(), Toast.LENGTH_SHORT).show();
  17. } catch (IOException e) {
  18. Log.e(TAG, "error in getting response get request okhttp");
  19. }
  20. }
  21. else
  22. {
  23. btnLock.setText("Enable");
  24. txtStatus.setText("Status: Unlock");
  25.  
  26. OkHttpClient httpClient = new OkHttpClient();
  27.  
  28. String url = "magilock.epizy.com/ChangeStatus.php?lock=0";
  29. Request request = new Request.Builder()
  30. .url(url)
  31. .build();
  32.  
  33. Response response = null;
  34. try {
  35. response = httpClient.newCall(request).execute();
  36. Toast.makeText(getActivity(), response.body().toString(), Toast.LENGTH_SHORT).show();
  37. } catch (IOException e) {
  38. Log.e(TAG, "error in getting response get request okhttp");
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement