summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/com/wireguard')
-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);
}