Code example for ReferenceQueue

0
 
	private static BinderPlayerHater sInstance;
	private final IPlayerHaterBinder mBinder;
	private final SparseArray<WeakSongReference> mSongs = new SparseArray<WeakSongReference>();
	private final SparseArray<BasicSong> mBasicSongs = new SparseArray<BasicSong>();
	private final ReferenceQueue<Song> mQueue = new ReferenceQueue<Song>();
 
	public static BinderPlayerHater get(IPlayerHaterBinder binder) {
		if (sInstance == null) {
			sInstance = new BinderPlayerHater(binder);
		} 
		return sInstance;
	} 
 
	public static void detach() { 
		sInstance = null;
	} 
 
	private BinderPlayerHater(IPlayerHaterBinder binder) {
		mBinder = binder;
	}