When to deregister a java/android object from another -


in oo think not uncommon object register object (perhaps singleton) callbacks.

in c++ think not uncommon registration in constructor or super class constructor of object being registered , deregistration destructor. gives assurances right timing.

i have 2 questions. best strategy achieve in java in general, given lack of destructor? in android, if object member of activity or fragment, guess object should registered , deregistered within 2 of on... methods in activity or fragment. think may hard know when object destroyed. 2 on... methods in activity or in fragment best use this?

additionally, perhaps less common, if object referenced number of other objects can 1 decide deregister on basis going out of scope , how or can 1 deregister based on other state implies on balance happy no longer receive call backs?


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -