Loading formats...
5, Saving an activity's state chapter 1 Android Application Development Cookbook 2nd
L
Le Hoang Long
0 views • Aug 15, 2016
Description
Saving an activity's state
The mobile environment is very dynamic, with users changing tasks much more often than on desktops. With generally fewer resources on a mobile device, it should be expected that your application will be interrupted at some point. It's also very possible that the system will
shut down your app completely to give additional resources to the task at hand. It's the nature of mobiles. A user might start typing something in your app, be interrupted by a phone call, or switch
over to another app to send a text message, and by the time they get back to your app, the system may have closed it down completely to free up the memory. To provide the best user experience, you need to expect such behavior and make it easier for your user to resume
from where they left off. The good thing is that the Android OS makes this easier by providing callbacks to notify your app of state changes.
In this recipe, you'll see how to handle the onSaveInstanceState() and
onRestoreInstanceState() callbacks to save your application's state. We will demonstrate this by creating a counter variable and increment it each time the Count button is pressed. We will also have an EditText and a TextView widget to see their default behavior.
The mobile environment is very dynamic, with users changing tasks much more often than on desktops. With generally fewer resources on a mobile device, it should be expected that your application will be interrupted at some point. It's also very possible that the system will
shut down your app completely to give additional resources to the task at hand. It's the nature of mobiles. A user might start typing something in your app, be interrupted by a phone call, or switch
over to another app to send a text message, and by the time they get back to your app, the system may have closed it down completely to free up the memory. To provide the best user experience, you need to expect such behavior and make it easier for your user to resume
from where they left off. The good thing is that the Android OS makes this easier by providing callbacks to notify your app of state changes.
In this recipe, you'll see how to handle the onSaveInstanceState() and
onRestoreInstanceState() callbacks to save your application's state. We will demonstrate this by creating a counter variable and increment it each time the Count button is pressed. We will also have an EditText and a TextView widget to see their default behavior.
Discover more
More from this user
03:43
Taekwondo, tkd , viet nam 20250508_184406
Le Hoang Long
01:05
Taekwondo, tkd , viet nam 20250505_195102
Le Hoang Long
02:42
Taekwondo, tkd , viet nam 20250428_190455
Le Hoang Long
01:39
Taekwondo, tkd , viet nam 20250428_200148
Le Hoang Long
00:03
Taekwondo, tkd , viet nam 20250428_200332
Le Hoang Long
04:57
Taekwondo, tkd ,20250327_194553
Le Hoang Long
Related videos
37:43
4, Returning a result from an activity chapter 1 Android Application Development Cookbook 2nd Edition
Le Hoang Long
10:43
1, Tạo activity và intent chương 1 Android Application Development Cookbook, 2nd Edition
Le Hoang Long
13:25
2, Di chuyển giữa các activity chương 1 Android Application Development Cookbook, 2nd Edition
Le Hoang Long
16:04
3, Truyền dữ liệu giữa các activity chương 1 Android Application Development Cookbook 2nd Edition
Le Hoang Long
26:18
3, Passing data to another activity chapter 1 Android Application Development Cookbook 2nd Edition
Le Hoang Long
06:08
#14 Android Application Development Tutorial_ Android Activity Screen Orientation Part 2 [HD 1080p] - YouTube
JIUT University