Created
October 20, 2013 22:52
-
-
Save steveliles/7076351 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package androidconcurrency.chapter4; | |
import android.os.Bundle; | |
import android.support.v4.app.FragmentActivity; | |
/** | |
* Adds support for isChangingConfigurations when minSdkVersion | |
* targets api-levels below 11. | |
* | |
* Unfortunately onSaveInstanceState is invoked AFTER onPause, | |
* so on platforms below 11 isChangingConfigurations will only | |
* report correctly in onStop() or onDestroy(). | |
*/ | |
public class CompatibleActivity extends FragmentActivity { | |
private boolean isConfigChange; | |
@Override | |
protected void onSaveInstanceState(Bundle outState) { | |
super.onSaveInstanceState(outState); | |
isConfigChange = true; | |
} | |
@Override | |
public boolean isChangingConfigurations() { | |
if (android.os.Build.VERSION.SDK_INT >= 11) | |
return super.isChangingConfigurations(); | |
else | |
return isConfigChange; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment