为什么super.onDestroy()在Java中 - Android的那张上面的析构函数?那张、函数、onDestroy、super

2023-09-12 11:20:37 作者:旧梦如风

我是新的java开发!可能有人告诉我...根据该逻辑 super.onDestroy(); 的析构函数去在上面?例如:

I am new in java development! May someone tell me... according to which logic super.onDestroy(); in destructors goes on top? for example:

protected void onDestroy() {        
    super.onDestroy();
    releaseMediaPlayer();
}

而不是

protected void onDestroy() {        
    releaseMediaPlayer();
    super.onDestroy();
}

如C ++,OBJ-C,帕斯卡,等等??

like c++, obj-c, pascal, etc ??

推荐答案

这真的取决于你想要做你的的onDestroy 的东西。这是super.onDestroy做(按顺序):

It really depends on what you want to do in your onDestroy. This is what super.onDestroy does (in that order):

关闭该活动是管理任何对话框。 关闭酶活性管理任何光标。 在关闭所有打开搜索对话框

如果你把里面的的onDestroy 逻辑事做这三样东西是确实的android用,那么你可能担心订单。否则,在大多数的情况下,也没有关系。

If the logic you put inside onDestroy has something to do with those three things that android does, then you may have to worry about the order. Otherwise, and in most of the cases, it does not matter.