summaryrefslogtreecommitdiffhomepage
path: root/app/src/main
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2017-08-07 18:42:38 -0500
committerSamuel Holland <samuel@sholland.org>2017-08-07 18:42:38 -0500
commit91620845b99d7d6a0e119be688f1281f2b5b30ef (patch)
tree967456b7df2ff0ac8cd261dbb4e8b3a55075cea3 /app/src/main
parentb5ca7829719fb6860b6228db8994d00b31cc1abd (diff)
ProfileActivityFragment: Fix service connection tracking
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/com/wireguard/android/ProfileActivityFragment.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/app/src/main/java/com/wireguard/android/ProfileActivityFragment.java b/app/src/main/java/com/wireguard/android/ProfileActivityFragment.java
index da394204..9ec9f51d 100644
--- a/app/src/main/java/com/wireguard/android/ProfileActivityFragment.java
+++ b/app/src/main/java/com/wireguard/android/ProfileActivityFragment.java
@@ -15,13 +15,27 @@ public class ProfileActivityFragment extends Fragment implements ServiceConnecti
public void onAttach(Context context) {
super.onAttach(context);
activity = (ProfileActivity) context;
- activity.addServiceConnectionListener(this);
- service = activity.getService();
}
@Override
public void onDetach() {
super.onDetach();
+ activity = null;
+ }
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ activity.addServiceConnectionListener(this);
+ // If the service is already connected, there will be no callback, so run the handler now.
+ final ProfileServiceInterface service = activity.getService();
+ if (service != null)
+ onServiceConnected(service);
+ }
+
+ @Override
+ public void onStop() {
+ super.onStop();
activity.removeServiceConnectionListener(this);
}