@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
((CustomApplication) getApplication()).detach(this);
}在生成PMD报告时,我得到了这个错误:在方法的末尾应该调用超级。通常,您最终会将超级方法保留在顶部(第一个语句),以便它的父类首先被称为初始化。
发布于 2017-06-09 16:02:36
根据这个所以,只要密钥不碰撞,在什么地方叫它并不重要。他们应该是等价物。
只要您的键不发生冲突(例如,ID与Android内部使用的ID相同),两者是相同的。
但话虽如此,谷歌关于活动的生命周期的文档显示,这是在最后添加的。不过,我仍然会这样做:
// invoked when the activity may be temporarily destroyed, save the instance state here
@Override
public void onSaveInstanceState(Bundle outState) {
out.putString(GAME_STATE_KEY, mGameState);
out.putString(TEXT_VIEW_KEY, mTextView.getText());
// call superclass to save any view hierarchy
super.onSaveInstanceState(out);
}https://stackoverflow.com/questions/17992284
复制相似问题