What is a OnCreate method in android

后端 未结 5 1948
北恋
北恋 2020-12-08 01:09

I am new to android trying to understand what the below method does

public void onCreate(Bundle savedInstanceState)
{
        super.onCreate(savedInstanceS         


        
相关标签:
5条回答
  • 2020-12-08 01:35

    Bundle is used to save & recover state information for your activity. In instances like orientation changes or killing of your app or any other scenario that leads to calling of onCreate() again, the savedInstanceState bundle can be used to reload the previous state information. Familiarity with this article about Activity lifecycle will help.

    0 讨论(0)
  • 2020-12-08 01:55

    If you save the state of the application in a bundle (typically non-persistent, dynamic data in onSaveInstanceState), it can be passed back to onCreate if the activity needs to be recreated (e.g., orientation change). If the orientation changes(i.e rotating your device from landscape mode to portrait and vice versa), the activity is recreated and onCreate() method is called again, so that you don't lose this prior information. If no data was supplied, savedInstanceState is null.

    For further information http://developer.android.com/guide/topics/resources/runtime-changes.html

    0 讨论(0)
  • 2020-12-08 01:59

    First super.onCreate(savedInstanceState); calls the method in the superclass and saved InstanceState of the activity if any thing damage the activity so its saved in instanceState so when reload the activity it will be the same before.

    0 讨论(0)
  • 2020-12-08 02:02

    Since the onCreate method is overridden, the super keyword is used to call the onCreate method of the base class. I think

    0 讨论(0)
  • 2020-12-08 02:02

    super is used to call the parent class constructor

    super.onCreate(savedInstanceState); calls the onCreate() method, not the constructor, of the superclass.

    0 讨论(0)
提交回复
热议问题