diff options
author | Samuel Holland <samuel@sholland.org> | 2017-08-07 18:42:38 -0500 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2017-08-07 18:42:38 -0500 |
commit | 00a755f46f9e06c61cdcf2a5e31b3b3aaefe0207 (patch) | |
tree | 967456b7df2ff0ac8cd261dbb4e8b3a55075cea3 /app | |
parent | 372477d0e02e5a6c71af62b10643d55d4c7b9bf5 (diff) |
ProfileActivityFragment: Fix service connection tracking
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/com/wireguard/android/ProfileActivityFragment.java | 18 |
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); } |