示例#1
0
 @Override
 protected void onResume() {
   super.onResume();
   if (!LocationService.isRunning()) {
     mServiceToggle.setChecked(false);
     mUserNameEntry.setEnabled(true);
     mUserNameEntry.setText(Helpers.getUserId());
   } else {
     mUserNameEntry.setEnabled(false);
     mUserNameEntry.setText(Helpers.getUserId());
     mServiceToggle.setChecked(true);
     mServiceToggle.setEnabled(true);
   }
 }
示例#2
0
 @Override
 public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
   switch (compoundButton.getId()) {
     case R.id.switch_track_location:
       Intent service = new Intent(this, LocationService.class);
       if (b) {
         Helpers.setUserId(mUserNameEntry.getText().toString());
         startService(service);
         mUserNameEntry.setEnabled(false);
       } else {
         stopService(service);
         mUserNameEntry.setEnabled(true);
       }
       Helpers.setServiceEnabled(b);
   }
 }