
protected voID onDestroy() { //option 1: callback before or ... super.onDestroy(); //option 2: callback after super.onDestroy();} (现在我担心:如果super.onDestroy太快,它将永远不会到达选项2.)
解决方法 当你调用super.onDestroy()时会发生这种情况.Android Source
protected voID onDestroy() { mCalled = true; // dismiss any dialogs we are managing. if (mManagedDialogs != null) { final int numDialogs = mManagedDialogs.size(); for (int i = 0; i < numDialogs; i++) { final Dialog dialog = mManagedDialogs.valueAt(i); if (dialog.isShowing()) { dialog.dismiss(); } } } // also dismiss search dialog if showing // Todo more generic than just this manager SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchManager.stopSearch(); // close any cursors we are managing. int numCursors = mManagedCursors.size(); for (int i = 0; i < numCursors; i++) { ManagedCursor c = mManagedCursors.get(i); if (c != null) { c.mCursor.close(); } }} 从本质上讲,这意味着如果您在代码之前或之后调用它并不重要.
总结以上是内存溢出为你收集整理的Android初学者:onDestroy全部内容,希望文章能够帮你解决Android初学者:onDestroy所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)