Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. @SuppressLint("HandlerLeak")
  2. private void configureHandler(){
  3. MainActivity.sHandler = new Handler() {
  4. @Override
  5. public void handleMessage(Message timeMsg) {
  6. super.handleMessage(timeMsg);
  7. long currentTime = Long.valueOf(timeMsg.obj.toString());
  8. int secs = (int) (currentTime / 1000);
  9. int mins = secs / 60;
  10. secs = secs % 60;
  11. setCurrentRentTime(mins, secs);
  12. }
  13. };
  14. }
  15.  
  16. private void setCurrentRentTime(int mins, int secs){
  17. currentRentTime.setText("" + mins + ":" + String.format("%02d", secs));
  18. }
  19.  
  20. private ServiceConnection myConnection = new ServiceConnection() {
  21. @Override
  22. public void onServiceConnected(ComponentName name, IBinder service) {
  23. RentService.LocalBinder binder = (RentService.LocalBinder) service;
  24. rentService = binder.getService();
  25. rentService.startStop();
  26. isBound = true;
  27. }
  28.  
  29. @Override
  30. public void onServiceDisconnected(ComponentName name) {
  31. isBound = false;
  32. }
  33. };
  34.  
  35. private void startService(){
  36. intent = new Intent(this, RentService.class);
  37. bindService(intent, myConnection, Context.BIND_AUTO_CREATE);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement