Android interview question Activity, androidactivity
- Activity Four startup Modes
Standard, singleTop, singleTask, and singleInstancestandard: when an Activity is activated (startActivity), the Activity instance is created and placed into the task stack. singleTop: if an instance of the Activity exists at the top of the stack of the task, the instance is reused. Otherwise, a new instance is created and placed on the top of the stack (even if the Activity instance already exists in the stack, instances will be created as long as they are not at the top of the stack ). SingleTask: if the Activity to be activated exists in the task stack, you do not need to create it. You only need to place the Activity to the top of the stack, and popsingleInstance for all the Activity instances above the Activity: If the MainActivity instance is created in the task stack of Application 1, if application 2 also needs to activate the MainActivity, it does not need to be created, the two applications share the Activity instance.
- Activity display start and hide start
Show start directly set class start intent
Implicit startup (1) Matching Based on Action and Category (2) Matching Based on Action and Data (3) Matching Based on the mimeType attribute of action and data (4) A single Activity can have multiple <intent-filter> </intent-filter> pairs. If one of them is matched, the Activity can be started.
Static and Dynamic use
- Activity Lifecycle
OnCreate-> onStart-> onResume-> onPause-> onStop-> onDestroy
OnAttatch-> onCreate-> onCreateView-> onActivityCreated-> onStart-> onResume-> onPause-> onStop-> onDestoryView-> onDestory-> onDetach
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.