Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- protected void onStart() {
- super.onStart();
- PreferenceManager.getDefaultSharedPreferences(this)
- .registerOnSharedPreferenceChangeListener(this);
- mRequestLocationUpdatesButton = (Button) findViewById(R.id.request_location_updates_button);
- mRemoveLocationUpdatesButton = (Button) findViewById(R.id.remove_location_updates_button);
- mRequestLocationUpdatesButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (!checkPermissions()) {
- requestPermissions();
- } else {
- mService.requestLocationUpdates();
- }
- }
- });
- mRemoveLocationUpdatesButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- mService.removeLocationUpdates();
- }
- });
- // Restore the state of the buttons when the activity (re)launches.
- setButtonsState(Utils.requestingLocationUpdates(this));
- // Bind to the service. If the service is in foreground mode, this signals to the service
- // that since this activity is in the foreground, the service can exit foreground mode.
- bindService(new Intent(this, LocationUpdatesService.class), mServiceConnection,
- Context.BIND_AUTO_CREATE);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement