<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Mobile_App_Development_2022W_Lecture_14</id>
	<title>Mobile App Development 2022W Lecture 14 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://homeostasis.scs.carleton.ca/wiki/index.php?action=history&amp;feed=atom&amp;title=Mobile_App_Development_2022W_Lecture_14"/>
	<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Mobile_App_Development_2022W_Lecture_14&amp;action=history"/>
	<updated>2026-04-06T01:53:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://homeostasis.scs.carleton.ca/wiki/index.php?title=Mobile_App_Development_2022W_Lecture_14&amp;diff=23873&amp;oldid=prev</id>
		<title>Soma: Created page with &quot;==Video==  Video from the lecture given on March 9, 2022 is now available: * [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec14-20220309.m4v video] * [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec14-20220309.cc.vtt auto-generated captions] Video is also available through Brightspace (Resources-&gt;Zoom Meetings (Recordings, etc.)-&gt;Cloud Recordings tab).  Note that here you&#039;ll also see chat messages.  ==Notes=...&quot;</title>
		<link rel="alternate" type="text/html" href="https://homeostasis.scs.carleton.ca/wiki/index.php?title=Mobile_App_Development_2022W_Lecture_14&amp;diff=23873&amp;oldid=prev"/>
		<updated>2022-03-09T20:06:01Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==Video==  Video from the lecture given on March 9, 2022 is now available: * [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec14-20220309.m4v video] * [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec14-20220309.cc.vtt auto-generated captions] Video is also available through Brightspace (Resources-&amp;gt;Zoom Meetings (Recordings, etc.)-&amp;gt;Cloud Recordings tab).  Note that here you&amp;#039;ll also see chat messages.  ==Notes=...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Video==&lt;br /&gt;
&lt;br /&gt;
Video from the lecture given on March 9, 2022 is now available:&lt;br /&gt;
* [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec14-20220309.m4v video]&lt;br /&gt;
* [https://homeostasis.scs.carleton.ca/~soma/mad-2022w/lectures/comp1601-2022w-lec14-20220309.cc.vtt auto-generated captions]&lt;br /&gt;
Video is also available through Brightspace (Resources-&amp;gt;Zoom Meetings (Recordings, etc.)-&amp;gt;Cloud Recordings tab).  Note that here you&amp;#039;ll also see chat messages.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Lecture 14&lt;br /&gt;
----------&lt;br /&gt;
 - I&amp;#039;ll be grading midterms soon, so should be another week, sorry&lt;br /&gt;
   - first want to release A3&lt;br /&gt;
 - rest of term is on Android&lt;br /&gt;
 &lt;br /&gt;
Question for the day: why does textanalyzer-5 lose state when you rotate it,&lt;br /&gt;
but TapDemo doesn&amp;#039;t?&lt;br /&gt;
 - note that textanalyzer-5 keeps the text that you enter, it just&lt;br /&gt;
   forgets the mode you&amp;#039;re in.&lt;br /&gt;
&lt;br /&gt;
So what&amp;#039;s happening is the running activity is destroyed when you rotate the screen&lt;br /&gt;
 - and textanalyzer-5 doesn&amp;#039;t save the state properly&lt;br /&gt;
&lt;br /&gt;
What&amp;#039;s an activity?&lt;br /&gt;
 - the unit of execution in an android app&lt;br /&gt;
 - can have many activities&lt;br /&gt;
 - when you run an app in any way, you are actually running a specific activity&lt;br /&gt;
    - and of course there is a default activity that is run when&lt;br /&gt;
      you launch the app&lt;br /&gt;
 - when you have multiple screens, you can implement them as multiple activities&lt;br /&gt;
    - but really, it is about splitting up functionality, not the interface per se&lt;br /&gt;
&lt;br /&gt;
So in textanalyzer-5, the state variable analysisMode is forgotten because the activity was terminated and then restarted&lt;br /&gt;
 - note that EditText preserves its own state after rotation&lt;br /&gt;
 - but MainActivity doesn&amp;#039;t, we have to implement that functionality&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
onCreate in an activity is a method that is called when an activity is created&lt;br /&gt;
 - it has a single argument which is a Bundle&lt;br /&gt;
 - bundles are used to store state that can be saved and restored&lt;br /&gt;
&lt;br /&gt;
Basic idea with bundles&lt;br /&gt;
 - when your activity will be terminated, save state into a bundle&lt;br /&gt;
 - when your activity is created again, restore state from the given bundle&lt;br /&gt;
&lt;br /&gt;
Bundles are dictionaries that can hold different types of data&lt;br /&gt;
 - so key, value, with the value being able to have different types&lt;br /&gt;
    - and the key is a string&lt;br /&gt;
 - the Android runtime manages the instance state bundles,&lt;br /&gt;
   we just have to put data in and pull data out at the right times&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You should play with TapDemo and see when the different activity lifecycle methods are called&lt;br /&gt;
 - when you rotate the screen, switch to another app, terminate an app, etc&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So, why does Android terminate the activity when the screen is rotated?&lt;br /&gt;
 - because the interface has to be redrawn anyway, easist way is to&lt;br /&gt;
   kill the activity and start it again with new screen geometry&lt;br /&gt;
&lt;br /&gt;
What about iOS apps?  Do they have a lifecycle?&lt;br /&gt;
 - yes definitely, much the same as Android&lt;br /&gt;
 - however, by default much of the state management is handled automatically&lt;br /&gt;
    - but you can change it&lt;br /&gt;
&lt;br /&gt;
How can we fix TapDemo so that it shows the proper count after rotation?&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Soma</name></author>
	</entry>
</feed>