Lesson 2 Flashcards

Connect to the Internet

1
Q

log messages

A

messages to communicate information about application

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

log levels;

A

WTF (rarely/never used), error, warn, info, () debug, verbose “WEW DIV”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

log syntax

A

log.x(String TAG, String message); typically use class name as TAG

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

typical ScrollView height, width

A

android: layout_height = “wrap_content”
android: layout_width=”match_parent”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Res folder types

A

holds resources; Strings, images, layouts.

Layouts: XML layouts
Animator: XML for property animations
Values: XML files that contain simple values, such as strings or integers
Anim: XML for tween animations

MIpmap: drawable launcher icon files
Drawable: visual files

Raw: arbitrary raw files

MEnu: XML for application menus
Xml: arbitrary XML

Color: XML for colors

“LAVA MiD R MeX (of) Color”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

get layout in res how?

A

by calling R.layouts.; uses folder res/layouts/ hierarchy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

get string in res how?

A

in res/values/strings.xml, call getString

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

set up layouts how/where?

A

in Android xml

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

xml menu orderInCategory

A

the order an item appears in a menu

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

action bar

A

above activity window, contains overflow menu, menu items are actions. can show buttons if room (showAsAction=”ifRoom”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

toolbar widget

A

generalized action bar; animated in and out

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

instantiate menu how?

A

in Java activity, override onCreateOptionsMenu

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how to add new resource type

A

right click “res” folder, add new resource directory, pick appropriate resource type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

code for inflating menu

A

@Override
public boolean onCreateOptionsMenu (Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
“OnCOM”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Uri.Builder

A

build uri from base, then parameters (such as search, and sort)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

url and uri

A

url is subset of uri

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Uri.Builder syntax

A
Uri builtUri = Uri.parse(GITHUB_BASE_URL).buildUpon().appendQueryParameter(PARAM_QUERY, githubSearchQuery).appendQueryParameter(t).build();
        // building blocks of URI building:
        // GITHUB_BASE_URL = http://....
        // PARAM_QUERY = "q"
        // PARAM_SORT = "sort"
        URL url = null;
        try {
            url = new URL(builtUri.toString());
        } catch (MalformedURLException e){
            e.printStackTrace();
        }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

do things when menu button pressed syntax

A

In activity,
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemThatWasClickedId = item.getItemId();
if (itemThatWasClickedId == R.id.action_search)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

where to add permissions?

A

declare permissions in manifest

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

main thread term in android

A

“Single User Interfacing Thread”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

network on which thread?

A

secondary execution thread,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

AsyncTask runs, publishes to where?

A

Run task on background thread

Publish results on UI (main) thread

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

UI thread parts

A

Handler, Message Queue; run and processes messages including from other threads

24
Q

AsyncTask parts, types, generic or not?

A
generic class (parametrized types in constructor)
"ParProRes"
Params, Progress, Result: type sent to Task, publishing type to update progress, type of result of task completion
25
Q

3 (4) corresponding override-able functions in Async tasks

A

doInBackground, onProgressUpdate, onPostExecute, (onPreExecute)
call Execute to execute task with parameters
“DOIB OPU OPE OPE)

26
Q

Anko

A

library for layouts, helpers, coroutines, and SQLite

27
Q

AsyncTask usage, class, doInBackground

A

create a class that extends async task, override doInBackground

28
Q

URL…urls syntax significance

A

varag, variable # of args.

29
Q

URL…urls syntax significance

A

varag, variable # of args.

30
Q

steps to network call

A
  1. create network task;
    a. doInBackground to make network call
    b. onPostExecute to use network results
  2. use network task where needed
31
Q

how to look for source of error with logs

A

“caused by” in logcat

32
Q

member variables naming convention

A

Non-public, non-static field names start with m; “my” (just to know why the ‘m’<> s; not useful.

33
Q

member variables naming convention

A

m<>

34
Q

member variable

A

In object-oriented programming, a member variable (sometimes called a member field) is a variable that is associated with a specific object, and accessible for all its methods (member functions).

35
Q

layout_gravity = “center” does what?

A

android:layout_gravity sets the gravity of the View or Layout relative to its parent; Gravity specifies how a component should be placed in its group of cells.

36
Q

JSON stands for

A

Java Script Object Notation

37
Q

why JSON used for web?

A

Its format is syntactically identical to the code for creating JavaScript objects. JS programs can use standard functions to read JSON data.

38
Q

Object:
name
first = John
last = Chuter

A

{“name”:
{“first”:”John”,
“last”:”Chuter”}
}

39
Q

JSON key idea1

A

key value pairs

40
Q

JSON key idea2

A

objects inside {}, values can be objects

41
Q

JSON key idea3

A

key is string; “”, value can be object, string, or raw number

42
Q

JSON key idea4

A
objects inside {}, contain list of key-value pairs separated by commas
{ 
    "k1":v1,
    "k2":v2
}
43
Q

where permissions

A

in manifest

44
Q

permissions tag, where

A

manifest parent

45
Q

AsyncTask doInBackground usage

A

override in class extending AsyncTask (to perform task in background; return of task is what is passed into onPostExecute

46
Q

4 steps of AsyncTask, detail

A

The 4 steps
When an asynchronous task is executed, the task goes through 4 steps:

  1. onPreExecute(), invoked on the UI thread before the task is executed. This step is normally used to setup the task, for instance by showing a progress bar in the user interface.
  2. doInBackground(Params…), invoked on the background thread immediately after onPreExecute() finishes executing. This step is used to perform background computation that can take a long time. The parameters of the asynchronous task are passed to this step. The result of the computation must be returned by this step and will be passed back to the last step. This step can also use publishProgress(Progress…) to publish one or more units of progress. These values are published on the UI thread, in the onProgressUpdate(Progress…) step.
  3. onProgressUpdate(Progress…), invoked on the UI thread after a call to publishProgress(Progress…). The timing of the execution is undefined. This method is used to display any form of progress in the user interface while the background computation is still executing. For instance, it can be used to animate a progress bar or show logs in a text field.
  4. onPostExecute(Result), invoked on the UI thread after the background computation finishes. The result of the background computation is passed to this step as a parameter.
47
Q

Java Class Constructors Syntax

A
Class ClassName {
    ClassName(type param1, type param2){
        // init code
    }
}
48
Q

Java access control

A

Public | Y | Y | Y | Y
Protected| Y | Y | Y | N
(no mod) | Y | Y | N | N
Private | Y | N | N | N

49
Q

get context from activity, when in activity

A

this (this@Activity)

50
Q

get context from activity, when outside activity

A

MainActivity.this

51
Q

add to a textView without replacing text

A

mTextView.append(text)

52
Q

Override onCreateOptionsMenu to inflate the menu for this Activity

A

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.forecast, menu);
return true;
}

53
Q

internal, external

A

internal, external to the app. Primary + secondary external; secondary often SD card.

54
Q

layout_gravity

A

android:layout_gravity Gravity specifies how a component should be placed in its group of cells.
; of
public static class LinearLayout.LayoutParams

android: gravity sets the gravity of the contents (i.e. it’s subviews) of the View it’s used on.
android: layout_gravity sets the gravity of the View or Layout relative to its parent.
https: //stackoverflow.com/questions/3482742/difference-between-gravity-and-layout-gravity-on-android

55
Q

“A good app should be like a good…”

A

“butler, giving what you want before you must ask for it”

applies to save, refresh.

56
Q

“coupling a background operation with a foreground component, the activity.” is bad or good

A

BAD