標籤:des android style class code c
super.onDestroy(); 的問題。
注意:沒有顯式地在自己的方法中調用父類Activity的onDestroy是會報錯的。
我的問題很簡單,在我覆蓋的onDestroy(),方法中需要調用父類的onDestroy。
我就是不懂調用的時機,就像下面兩種。
?
1 2 3 4 |
protected void onDestroy() { <br style= "margin: 0px; padding: 0px;" > super .onDestroy();<br style= "margin: 0px; padding: 0px;" > // My code;<br style="margin: 0px; padding: 0px;"> }<br style= "margin: 0px; padding: 0px;" > |
?
1 2 3 4 |
protected void onDestroy() { <br style= "margin: 0px; padding: 0px;" > // My code;<br style="margin: 0px; padding: 0px;"> super .onDestroy();<br style= "margin: 0px; padding: 0px;" > }<br style= "margin: 0px; padding: 0px;" ><br style= "font: 14px/24px Tahoma; margin: 0px; padding: 0px; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; font-size-adjust: none; font-stretch: normal; -webkit-text-stroke-width: 0px;" ><span style= "font: 14px/24px Tahoma; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; font-size-adjust: none; font-stretch: normal; -webkit-text-stroke-width: 0px;" >請教大神,哪一種才是正確的寫法?</span> |
分享到:
------解決方案--------------------
一般是這樣的:
protected void onDestroy() {
// My code;
super.onDestroy();
}
但取決於你的代碼在onCreate的時候如何調用
------解決方案--------------------
如果嚴格點。必須是這樣的順序,在把你要做的處理完畢後,再釋放父類資源
protected void onDestroy() {
// My code;
super.onDestroy();
}
------解決方案--------------------
一般沒有區別的 如果你的代碼只是做你自己的事情 沒啥循序關聯性 當然 前提是沒有引用到父類已經釋放的資源(基本沒遇見過,都是幹自己的)