Advertisement
pepoflex

glap

Jan 12th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1.     @Override
  2.     protected void onStart() {
  3.         super.onStart();
  4.         PreferenceManager.getDefaultSharedPreferences(this)
  5.                 .registerOnSharedPreferenceChangeListener(this);
  6.  
  7.         mRequestLocationUpdatesButton = (Button) findViewById(R.id.request_location_updates_button);
  8.         mRemoveLocationUpdatesButton = (Button) findViewById(R.id.remove_location_updates_button);
  9.  
  10.         mRequestLocationUpdatesButton.setOnClickListener(new View.OnClickListener() {
  11.             @Override
  12.             public void onClick(View view) {
  13.                 if (!checkPermissions()) {
  14.                     requestPermissions();
  15.                 } else {
  16.                     mService.requestLocationUpdates();
  17.                 }
  18.             }
  19.         });
  20.  
  21.         mRemoveLocationUpdatesButton.setOnClickListener(new View.OnClickListener() {
  22.             @Override
  23.             public void onClick(View view) {
  24.                 mService.removeLocationUpdates();
  25.             }
  26.         });
  27.  
  28.         // Restore the state of the buttons when the activity (re)launches.
  29.         setButtonsState(Utils.requestingLocationUpdates(this));
  30.  
  31.         // Bind to the service. If the service is in foreground mode, this signals to the service
  32.         // that since this activity is in the foreground, the service can exit foreground mode.
  33.         bindService(new Intent(this, LocationUpdatesService.class), mServiceConnection,
  34.                 Context.BIND_AUTO_CREATE);
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement