Android 父類super.onDestroy();的有關問題

來源:互聯網
上載者:User

標籤: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();
}
------解決方案--------------------
一般沒有區別的   如果你的代碼只是做你自己的事情  沒啥循序關聯性  當然  前提是沒有引用到父類已經釋放的資源(基本沒遇見過,都是幹自己的)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.