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