Model Solutions to inclass Quiz 1

Model Solutions to inclass Quiz 1

by Tony deLaubenfels -
Number of replies: 6

Include questions and references


In reply to Tony deLaubenfels

Re: Model Solutions to inclass Quiz 1

by TJ Robison -

4. What is the significance/utility of the TAG constant declaration in our Activity activity?

The TAG constant has the class name as it's value, and is passed to logging functions in the activity. It helps identify the source of a particular log message. For example, in our program, is has the value "QuizActivity".

In reply to Tony deLaubenfels

Re: Model Solutions to inclass Quiz 1

by Ryan Conrardy -

5) What is a likely cause of a problem with the generation of an Android R.java file?  What are a couple things to try if there is a problem generating R.java?


a. A typo in the XML file may cause R.java to not generate for the last build.  Fixing the typo and re-saving should update the R file.  

b. Select Build-->Clean Project.  This rebuilds from scratch.

c. Changes to build.gradle file cause cause the R file to report problems.  Go to Tools-->Android-->Synch project with Gradle files to update the R file to the most recent changes.

d. Use Lint to check for errors and fix them manually.  Save files to update R file.  

In reply to Tony deLaubenfels

Re: Model Solutions to inclass Quiz 1

by Dawit Tsigie -

1. True or False? Justify your answer

Your app code must include a call to onCreate(...) to get things started

Solution: False, onCreate(...) or any of the the other Activity life cycle methods are not called by us. We override them in the activity subclasses and android calls them at the appropriate time. (pg. 58)

In reply to Tony deLaubenfels

Re: Model Solutions to inclass Quiz 1

by Akash Surti -

2) Why is it advisable to use the @override annotation (esp. in the context of the Activity lifecycle)? (cf. p 60 and Moodle post)

@override is a method telling the compiler to check if the method you override is the one you want to override. This makes it easier to parse the program.

- Angela, Galbrath, Michael, & Akash

Reference:

http://stackoverflow.com/questions/94361/when-do-you-use-javas-override-annotation-and-why

In reply to Tony deLaubenfels

Re: Model Solutions to inclass Quiz 1

by Eric Andow -

6. What is an intent?

An intent is a sent between elements of the OS.  It can be used for multiple purposes, like sending data or opening a new activity. Since the OS handles all intents, they can be explicit (within one application) or implicit (between different applications). 

In reply to Tony deLaubenfels

Model Solutions Quiz 1 Question 3

by Rollin Tschirgi -

Chell, Kat, Rollin, Tony

3. What is the significance/utility of the Bundle class with respect to the Activity lifecycle?

The Bundle class assigns strings to various data values and wraps them up in a single object. This makes it easy to save/retrieve data when an an Activity is created/paused/destroyed. It also helps when transferring data via intent extras because you only have to attach one extra to the intent. 

Sources:

BigNerdRanch TextBook
thenweboston Channel, youtube.com