Stop service if not logged in or no permissions
parent
ed72d03033
commit
9d1af6585b
|
@ -28,6 +28,7 @@
|
|||
android:name=".SettingsActivity"
|
||||
android:label="@string/settings_name"
|
||||
android:parentActivityName=".LoginActivity">
|
||||
<!-- Parent activity meta-data to support 4.0 and lower -->
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".LoginActivity"/>
|
||||
|
|
|
@ -199,7 +199,9 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
|||
// Get permission
|
||||
if (!checkLocationPermission(this)) {
|
||||
Log.d(TAG, "Location permission denied");
|
||||
//TODO: Turn off location updates
|
||||
// stopSelf();
|
||||
|
||||
//TODO: Ask the user to try again
|
||||
|
||||
} else {
|
||||
Log.d(TAG, "Location permission granted");
|
||||
|
@ -283,7 +285,7 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
|||
}
|
||||
else {
|
||||
Log.v(TAG, "Can't set location because user isn't logged in.");
|
||||
//TODO: So stop the damn service!
|
||||
stopSelf();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -205,18 +205,17 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
loadHeadersFromResource(R.xml.pref_headers, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
Log.v(TAG, "onBackPressed() called");
|
||||
public void signOut() {
|
||||
Log.v(TAG, "signOut() called");
|
||||
|
||||
// Get sharedPrefs
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
// Get sharedPrefs
|
||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
|
||||
// Stop LocationService
|
||||
// Stop LocationService
|
||||
Log.v(TAG, "Stopping location service...");
|
||||
stopService(new Intent(SettingsActivity.this, LocationService.class));
|
||||
editor.putBoolean("gps_switch",false);
|
||||
stopService(new Intent(SettingsActivity.this, LocationService.class));
|
||||
editor.putBoolean("gps_switch",false);
|
||||
|
||||
// Remove saved loggedInUser
|
||||
Log.v(TAG, "Removing saved user...");
|
||||
|
@ -228,11 +227,14 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
|
||||
// Return to LoginActivity and don't sign back in again
|
||||
setResult(SIGN_OUT, new Intent());
|
||||
}
|
||||
|
||||
// Finish the job
|
||||
// finish();
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (true) {
|
||||
signOut();
|
||||
}
|
||||
super.onBackPressed();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -275,6 +277,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|
|||
bindPreferenceSummaryToValue(findPreference("broadcast_priority"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue