I am trying get into Android programming, and for I am taken some examples from a book. In on of these example is requested to put the following code:
public class ExemploCicloVida extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Log.i(TAG, getClassName() + " onCreate() called on: " + icicle);
TextView t = new TextView(this);
t.setText("Exemplo de ciclo de vida de uma Activity.\nConsulte os logs no LogCat");
setContentView(t);
}
}
I wonder why Bundle object is always null on this case.
The savedInstanceState is a reference to a Bundle object that is passed into the onCreate method of every Android Activity.
onCreate is "Overridden" because Activity has an existing implementation that your class MainActivity is replacing with it's own implementation. you would say "implemented" if the method is only declared in an interface, but there is no implementation in a super class your are replacing.
onCreate() is called when the when the activity is first created. onStart() is called when the activity is becoming visible to the user.
The bundle will be null if there is no previously-saved state.
This is mentioned in the Activity
API 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