我正在使用Android应用程序,我按下主页按钮,我再次从启动图标打开应用程序。
哪个事件被解雇了?
因为当我再次打开应用程序时,布局丢失了......
这是on create method
的代码ON CREATE
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
INSTANCE = this;
Constants.initializeConstantsFromResources(this);
Controller.getInstance().setPreferences(PreferenceManager.getDefaultSharedPreferences(this));
if (Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_SHOW_FULL_SCREEN, false)) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
if (Controller.getInstance().getPreferences().getBoolean(Constants.PREFERENCES_GENERAL_HIDE_TITLE_BARS, true)) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
setProgressBarVisibility(true);
setContentView(R.layout.main);
mCircularProgress = getResources().getDrawable(R.drawable.spinner);
EventController.getInstance().addDownloadListener(this);
mHideToolbarsRunnable = null;
mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
buildComponents();
mViewFlipper.removeAllViews();
updateSwitchTabsMethod();
updateBookmarksDatabaseSource();
registerPreferenceChangeListener();
Intent i = getIntent();
if (i.getData() != null) {
// App first launch from another app.
addTab(false);
navigateToUrl(i.getDataString());
} else {
// Normal start.
int currentVersionCode = ApplicationUtils.getApplicationVersionCode(this);
int savedVersionCode = PreferenceManager.getDefaultSharedPreferences(this).getInt(Constants.PREFERENCES_LAST_VERSION_CODE, -1);
// If currentVersionCode and savedVersionCode are different, the application has been updated.
if (currentVersionCode != savedVersionCode) {
// Save current version code.
Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
editor.putInt(Constants.PREFERENCES_LAST_VERSION_CODE, currentVersionCode);
editor.commit();
// Display changelog dialog.
Intent changelogIntent = new Intent(this, ChangelogActivity.class);
startActivity(changelogIntent);
}
/*
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(Constants.PREFERENCES_BROWSER_RESTORE_LAST_PAGE, false)) {
if (savedInstanceState != null) {
String savedUrl = savedInstanceState.getString(Constants.EXTRA_SAVED_URL);
if (savedUrl != null) {
addTab(false);
navigateToUrl(savedUrl);
lastPageRestored = true;
}
}
}*/
boolean lastPageRestored = false;
// gaf - comienzo con la pagina inicial
String savedUrl = "file:///android_asset/startpage/index.html";
//String savedUrl = "http://servidor-cade.com";
//String savedUrl = "http://192.168.1.18:3636";
addTab(false);
navigateToUrl(savedUrl);
lastPageRestored = false;
//if (!lastPageRestored) {
// addTab(true);
//}
}
initializeWebIconDatabase();
startToolbarsHideRunnable();
}
答案 0 :(得分:0)
您应该阅读有关活动生命周期的信息。
您可以使用onStart()
或onResume()
。
看一下这个文档:
http://developer.android.com/training/basics/activity-lifecycle/pausing.html