You have an incorrectly designed application architecture.I'll start with what you're doing. onResume() - We need to move. onCreate()because the user will see new data (reconstruction of facilities) every time the application is stopped and resumed.Second, in development setContentView() used once for each activate.setContentView() to be installed before activate, otherwise you risk NPE.protected void onResume() {
super.onResume();
if (mSettings.contains("city")) {
cityOption = mSettings.getString("city", null);
if (cityOption != null) {
if (hasConnection(getBaseContext())) {
setContentView(R.layout.activity_sfera);
toolbar = (Toolbar) findViewById(R.id.myToolBar);
toolbar.setTitleTextColor(getResources().getColor(R.color.toolbar_title));
setSupportActionBar(toolbar);
As stated above, setContentView() For each activate, there must be one. No manipulation like this: etSearch.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
cityAdapter.getFilter().filter(s);
}
});
get_cityList();
} else {
setContentView(R.layout.layout_nointernet);
}
}
}
You want to point out that the user doesn't have the Internet? You can use other ways, starting with a simple dialogue or using fragments.About the mistake. It's a difficult code for me, but I'm sure the problem is in the wrong way.