I get some wierd logs, which obviously only occurs on Android-Devices with Versions below 3(checked with emulator). When you change the orientation and onCreate() or onRestoreInstanceState() is called with an Bundle that is not null it crashed
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_menu);}
if (savedInstanceState != null) {
mSlug = savedInstanceState.getString(KEY_SLUG, null);
}
}@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(KEY_SLUG, mSlug);
}@Override
protected void onRestoreInstanceState(Bundle outState) {
super.onRestoreInstanceState(outState);
if (outState != null) {
mSlug = outState.getString(KEY_SLUG, mSlug);
}
}
The LogCat-Log looks like: https://i.sstatic.net/WbivQ.png Does anybody got clue what is happening here?
Bundle.getString with 2 arguments is only available in API level 12 and later. You have to specify the default value yourself, rather than passing it as an argument.
You can check this yourself in the future by clicking the "Filter by API level" dropdown and selecting the appropriate API level in the upper right hand of the documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With