并不总是调用onDestroy().如果被调用,则只执行部分代码.
而且大部分时间在LogCat中我只看到消息"首先调用destroy的gps状态".这是为什么?
protected void onDestroy() {
super.onDestroy();
Log.d("on destroy called", "gps state on destroy called first");
editor.putBoolean("gpsOn", false);
Log.d("on destroy called", "gps state on destroy called second");
editor.commit();
Log.d("on destroy called", "gps state on destroy called third");
stopRouteTracking();
Log.d("on destroy called", "gps state on destroy called fourth");
}
Run Code Online (Sandbox Code Playgroud)