ProfileActivityFragment: Fix service connection tracking
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
372477d0e0
commit
00a755f46f
@ -15,13 +15,27 @@ public class ProfileActivityFragment extends Fragment implements ServiceConnecti
|
|||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
activity = (ProfileActivity) context;
|
activity = (ProfileActivity) context;
|
||||||
activity.addServiceConnectionListener(this);
|
|
||||||
service = activity.getService();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDetach() {
|
public void onDetach() {
|
||||||
super.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);
|
activity.removeServiceConnectionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user