Android: memory leaks due to member variables? -


I have developed an Android application that has a fragmented activity and several pieces on the tab's change. Each fragment is associated with a sequence, the logic of the section has been explained in different classes. The results of those calculations are displayed in several text scenes of the scene of the pieces that classes perform some complex calculations. There is a stop button in the view of the next piece, and the calculation of the class happens after clicking the stop button.

My question is now to protect the variables associated with each text view as the member variable of the related class within those visible members (text scenes and stop buttons) classes? Here I use the related code.

  Class Class AFragment spreads the piece {class A class A; ... Creatives on public view (...) {button stopbutton = (button) this.getActivity () FindViewById (R.id.btnStop); TextView timeLabel = (TextView) this.getActivity (). FindViewById (R.id.mTimeLabel); This.classA = new square (); This.classA.setAppElements (Timelabel, StopButton); } ...} class ClassA {TextView mTimeLabel; Button mStopButton; Public Zero SetApplations (TextViewLabel, Button StopButton) {this.mTimeLabel = timeLabel; This.mStopButton = stopButton; this. MStopButton.setOnClickListener (this.mStopListener); } Progress to show private zeros () {this.mTimeLabel.setText ("some text"); } Public Zero Stopping () {Clicking to Respond to Stop Button} OnClickListener mStopListener = New OnClickListener () {@Override Click Public Zero (see V) {ClassA.this.stop (); }}; ...}  

Is this code safe with respect to memory leaks? In the official Android documentation I have read that any object must not pass, which is bound to the AP reference from any member variable ().

To inform you the UI (the piece in your case) local board manager or bus (e.g. For Otto Eventbus). LocalBroadcastManager is fast (just use Reflections, which does not spread in the former ICS Android version and may be slow), but just simple. Hope it helps.

P.S.

P.P. If you do - make sure you can properly consider ideas in DIRESTOY ()

.

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -