In one of my android App, extending Activity, I use onResume() to refresh activity in return from PreferenceActivity, such this way ...
public class ListViewWebShort extends Activity {
ListView listView;
@Override
protected void onResume() {
super.onResume();
this.onCreate(null);
}
....
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_view);
// Get ListView object from xml
listView = (ListView) findViewById(R.id.list);
....
.. and here, App works as expected.
In another App, where I extend AppCompatActivity, the same onResume() method, makes my app crash or loop on start :
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener {
ListView listView;
ArrayAdapter<String> adapter;
....
@Override
protected void onResume() {
super.onResume();
this.onCreate(null);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
....
If I use requestWindowFeature(Window.FEATURE_NO_TITLE); before setContentView, I see in debug that App loops in getDelegate().setContentView(layoutResID), inside AppCompactActivity.java, but if I remove it, the app FCs in the same function. It really makes me drive crazy .. what am I missing?
Thanks in advance for any suggestion.