4.5.4. Overriding Activity Method onCreate

The onCreate method (Fig. 4.20) is called by the system:

• when the app loads

• if the app’s process was killed by the operating system while the app was in the background, and the app is then restored

• each time the configuration changes, such as when the user rotates the device or opens or closes a physical keyboard.

39      // called when MainActivity is first created40      @Override41      protected void onCreate(Bundle savedInstanceState)42      {43         super.onCreate(savedInstanceState);44         setContentView(R.layout.activity_main);45 46         // get references to the EditTexts47         queryEditText = (EditText) findViewById(R.id.queryEditText);48         tagEditText ...

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.