1) Intent filter is inside the initial activity you want to launch.
2)When you open the app it goes
onCreate
onStart
onResume
3)An activity is in pause as long as you can partially see it. Like Google Play's "Do you wish to install popup. The activity behind it, is currently in pause()
4)Once it is fully gone, it goes into onstop()
5) Why use onpause?
Why?
The classes that make up the Android SDK can be incredibly complex. For instance, both activities and fragments must perform a number of operations in order to function properly (i.e. managing life cycle, optimizing memory usage, drawing the layout to the screen, etc.). Requiring the client to make a call to the base class (often at the beginning of the method) ensures that these operations are still performed, while still providing a reasonable level of abstraction for the developer.
7)Onpause is good when you're sure the users want options like autosave. Such as drafting an email. In that case, it'll be a temporary save and it'll be fast. But operations like writing to a database should be implemented on OnStop. Otherwise you'll see the activity lag.
8)Use onResume to initalize components that were paused in OnPause();
9)OnStop is called when your app isn't visible anymore.
Eg. Using the multitasking button to switch from one app to the next
Eg. Switching from one activity to the next . When you hit the back button, the original activity will go into onrestart()
10) Onrestart() jumps into onstart() so you can perform tasks that are essential when the app starts for the first time or starting again, like checking if your gps is enabled.
11)If you rotate your screen, your current activity is killed and restarted from onCreate() (since it has to draw the layout all over again.)
In that case EditText text entered wouldn't be lost, but saved variable values may be lost.
So you can save variables before clearing the activity by using onsavedinstance() and accessing it with a bundle.
Add data to the bundle with .putint(String name,int value)
Call the superclass afterwards.
12)To access the saved data, use onrestorestate() after the super.onCreate(savedinstance), just be sure to check if the saved instance is null.
You can also implement it as a separate function just like onsavedinstance(), but in this case, it'll be called after the onStart() method and not right after onCreate()
2)When you open the app it goes
onCreate
onStart
onResume
3)An activity is in pause as long as you can partially see it. Like Google Play's "Do you wish to install popup. The activity behind it, is currently in pause()
4)Once it is fully gone, it goes into onstop()
5) Why use onpause?
- Stop animations or other ongoing actions that could consume CPU.
- Commit unsaved changes, but only if users expect such changes to be permanently saved when they leave (such as a draft email).
- Release system resources, such as broadcast receivers, handles to sensors (like GPS), or any resources that may affect battery life while your activity is paused and the user does not need them.
Why?
The classes that make up the Android SDK can be incredibly complex. For instance, both activities and fragments must perform a number of operations in order to function properly (i.e. managing life cycle, optimizing memory usage, drawing the layout to the screen, etc.). Requiring the client to make a call to the base class (often at the beginning of the method) ensures that these operations are still performed, while still providing a reasonable level of abstraction for the developer.
7)Onpause is good when you're sure the users want options like autosave. Such as drafting an email. In that case, it'll be a temporary save and it'll be fast. But operations like writing to a database should be implemented on OnStop. Otherwise you'll see the activity lag.
8)Use onResume to initalize components that were paused in OnPause();
9)OnStop is called when your app isn't visible anymore.
Eg. Using the multitasking button to switch from one app to the next
Eg. Switching from one activity to the next . When you hit the back button, the original activity will go into onrestart()
10) Onrestart() jumps into onstart() so you can perform tasks that are essential when the app starts for the first time or starting again, like checking if your gps is enabled.
11)If you rotate your screen, your current activity is killed and restarted from onCreate() (since it has to draw the layout all over again.)
In that case EditText text entered wouldn't be lost, but saved variable values may be lost.
So you can save variables before clearing the activity by using onsavedinstance() and accessing it with a bundle.
Add data to the bundle with .putint(String name,int value)
Call the superclass afterwards.
12)To access the saved data, use onrestorestate() after the super.onCreate(savedinstance), just be sure to check if the saved instance is null.
You can also implement it as a separate function just like onsavedinstance(), but in this case, it'll be called after the onStart() method and not right after onCreate()
No comments:
Post a Comment