如果我以下列方式在活动中使用侦听器:
// Read from the database
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// This method is called once with the initial value and again
// whenever data at this location is updated.
String value = dataSnapshot.getValue(String.class);
Log.d(TAG, "Value is: " + value);
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.w(TAG, "Failed to read value.", error.toException());
}
});
Run Code Online (Sandbox Code Playgroud)
附加匿名侦听器(未附加到变量的事件),我还需要删除它吗?
*我将onStart()它设置在并且需要它运行直到onStop()/onDestroy()
什么时候需要移除监听器?