Created
September 29, 2011 20:23
-
-
Save mharper/1251818 to your computer and use it in GitHub Desktop.
Simple activity class to demonstrate Android lifecycle
This file contains hidden or 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
public class LifecycleActivity extends Activity | |
{ | |
private int createCount = 0; | |
private int configCount = 0; | |
private String sentinel = ""; | |
/** Called when the activity is first created. */ | |
@Override | |
public void onCreate(Bundle savedInstanceState) | |
{ | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
Log.d("Lifecycle", "onCreate called " + createCount + " times, sentinel is '" + sentinel + "'."); | |
this.sentinel = "Been here, done that"; | |
createCount++; | |
} | |
/** Called when the activity is first created. */ | |
@Override | |
public void onStart() | |
{ | |
super.onStart(); | |
Log.d("Lifecycle", "onStart called"); | |
} | |
@Override | |
public void onConfigurationChanged(Configuration newConfig) | |
{ | |
super.onConfigurationChanged(newConfig); | |
Log.d("Lifecycle", "onConfigurationChanged called " + configCount + " times."); | |
configCount++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment