final Flashcards
SQL: databaseOpenHelper:
OnUpgrade()
«_space;if version is newer version is higher than old version. drop table statement, onCreate()
Greedy
finds the best language:
1) Values-EN-Rca
Match parent
size of parent
LifeCycle functions:
OnCreate(Bundle b) OnStart OnResume OnPause OnClose OnDestroy
Sharedpreference:
putstring, getstring if they don’t match you get default value not 0. are also used for saving files and such
Types of Log
Log.i Log.w Log.e Log.d Log.v
ListAdapter functions:
getCount(), getItem(), getItemId(), getView(), setOnItemClick(), setAdapter(), notifyItemsChanged()
SQL: databaseOpenHelper:
OnCreate()
«_space;SQL Creation statement
Log.i
informational messages
Android is
android is linux,
APK
zip file that has xml, java, png, jpg
Root tag
first tag being declared (not xml version tag), android.support.constraintlayout…
Android uses
android uses java and xml
FindViewById
returns null if not found in the layout.
Log.d
debug messages
SQL: databaseOpenHelper:
OnOpen()
«_space;all cases calls this
Toolbar items have what
Items have an Id, orderInCategory, icon, showAsAction
Log.w
warning messages
Parameter
id, layout_width etc.
XML is
case sensitive, well formed, must have closing tags.
toolbar showAsAction
showAsAction can be: always(always be icon), never(be text) or if room(text)
Log.v
verbose messages
Logging levels:
info, error, debug, verbose
What does Bundle return?
Bundle returns 0 or null
Toolbar OrderInCategory
to left has a small order category, to the right has large order category
Fragments for phone:
No frameLayout in XML
FindViewById() - returns null
OnEvents – whenever something happens you must startActivity (go from one activity to the other, second one has the frame layout)
Onclick events what happens for phone
either start a new activity (phone)
SQL: databaseOpenHelper:
OnDowngrade()
Wrap content
minimum size needed to show content
Name space part in XML:
android, app, tools
String XML format and how to reference it?
Value
to reference it – android:text=”@string/Key”
which gives - getResources().getString(R.string.Key);
how does Bundle and SharedPreferences work in the same way?
put – get(): put something get something ex. Put(name, value) get(name){returns value}
BUT
If you put in as a string and get an int, returns default value – must be matching data types
Fragments for tablet:
Has framLayout in XML
FindViewById() - returns not null
Both layouts are seen on one screen
LinearLayout – default orientation
horizontal
Log.e
error messages
if SharedPreferences cannot find a name
SharedPreferences has default answers if the name is not found
Onclick events what happens for tablet
you start a fragment transaction (tablet)
FragmentManager beginTransaction
.Add (frameLayout, Fragment) , .remove (Fragment), .replace (frameLayout, Fragment)
.commit();
Content values:
Put(Name, Value);
For all columns
one put statement for every column. Doesn’t get called unless you call insert()
SharedPreferences only gets called with what?
shared Preferences only gets called with commit();
For a linear Layout If first button is width = match parent where will the second button appear?
second button will not show (off screen on layout).
RelativeLayout – default orientation/position -
top left
What must you use for start activity
onActivityForResult(int requestCode) to start activity.
Where does the request code get sent for startActivity?
The request code gets sent to onActivityResult(requestCode, resultCode, intent) and the request code gets sent back
Where does the result come from for startActivity?
the result is from setResult(resultCode, intent).
Which was the first smartphone available that ran Android?
HTC Dream
Is the following XML code legal syntax: “item 1 “
Yes
Which folder would contain the resource: “R.drawable.a_picture”
res/drawable
Which folder would contain the strings.xml file for the German language?
values-de
When compiling your Android project, which gets compiled first?
XML files
Does Android version 4.4 (KitKat) natively support Fragments (not using the support library)?
Yes
Arrayadapter
displaying array of strings
Which function gets called first in the Android Lifecycle:
onCreate
Is the following XML tag legal syntax: “ Hello world “
No
What operating system is Android based on?
Linux
BaseAdapter
displaying complicated data
Does Android version 2.2 (Froyo) natively support Fragments (not using the support library)?
No
Is the following XML tag legal syntax: “<ul><li>Bananas </li><li> apples </li></ul> “
No
CursorAdapter
displaying results of SQL queries. Can handle mapping more than one value to more than one view ID.
getCount()
returns the number of items
Cursor c
holds the results from the SQL query
Which folder would contain the resource: “R.layout.first_page”
res/layout
Which file specifies the starting Activity for an application?
AndroidManifest.xml
What does the first parameter in getSharedPreferences(“a_string”, Context.MODE_PRIVATE)?
The file name
If the bundle parameter for the onCreate(Bundle savedInstance) is not null, which function gets called automatically?
onRestoreInstanceState(Bundle savedInstanceState)
Which function gets called last in the Android Lifecycle:
onDestroy
getItem(int position)
returns specific item
Long getItemId(int i)
returns the database id of the item at position i
When is the bundle parameter for the onCreate(Bundle savedInstance) null?
When the application is loaded for the first time
When you call putString(“string_one”, “string_two”), which string that represents the value (not name)?
“string_two”
View getView()
creates a view object to go in a row of the ListView
How to start a listview
doesn’t start gets without this:
Listview.setAdapter(od);
Od.notifyItemsChanged();
What order do the listView functions get called in?
First called: getCount second called: getView third called: getItem
getCount(# of items), then you call getItems(int I – always less than getCount params, string of I), getItemId(int I – database If of i) getItemId() important for onItemClick(int I, long ln), getView(int I, view v(recycled item that was scrolled off page and unused – to use memory), null)inflates the view from a layout.
what does the listview setAdapter(listAdapter obj) need?
The adapter object needs a layout.
for a relative layout If 2 buttons are width = match parent
only second button will show (buttons are laid overtop of each other)
relative layout has what layout options
toRightOf
toLeftOf
below
above
relative layout If second button is layout_above first button
second button will not show (off screen on layout)
Async 3 important functions
doInBackground()
onProgressUpdate()
onPostExecute()
Async will only work if you call what?
execute()
code for Async
AsyncTask
cursor functions
getCount() moveToFirst() moveToNext() getString(int columnIndex) getInt(int column) getColumnIndex(String columnName) isAfterLast()
what gets passed to onPostExecute
whatever gets passed from doInBackground gets passed to onpostexecute
parameters for onPostExecute
T3
parameters for DoInBackground
(T1 … args)
parameters for publishProgress
(T2…)
who calls publishProgress
we do
who calls onProgressUpdate
android calls
when can the GUI be updated
Can only update GUI on postExecute() or onProgressUpdate()
where can you only access the network
doInBackground()
Which function must you call to retrieve the saved string from the sharedPreferences call: putString(“string_one”, “string_two”)
getString(“string_one”, “string_three”)
Which function must you call to start an activity when you want to get data back?
startActivityForResult()
What function must you call to end an Activity?
finish()
If you call setResult(Activity.RESULT_OK), what will be the value of the request code parameter in onActivityResult(int request, int result, Intent data)?
Unknown
What is the proper format for creating a Toast message?
Toast.makeText(getApplicationContext(), “The message”, Toast.LENGTH_SHORT);
What design pattern is used when chaining many function calls for creating an AlertDialog: dialog.setMessage().setTitle()
.setPositiveButton().setNegativeButton()
.show();?
The builder pattern
Which of the following functions is required for implementing the ListAdapter interface
getCount
What is the corresponding SQL query to this function: db.query(true, “PURCHASES”, new String []{“Price”, “Quantity”}, “Quantity > ?”, new String[] {“10” }, null, null, null, null)?
Select distinct Price,Quantity from PURCHASES where Quantity > 10
When you write a ListView adapter class, which function gets called first when populating the ListView:
getCount
Which of the following functions causes a ListView to start the re-population of the list:
notifyDataSetChanged
This is a fragment of an SQL query clause: “ ? = ? AND ? NOT NULL”, new String [] { “Brandname”, “Nike”, “CUSTOMER_NAME”}. What will be the corresponding SQL Where clause:
Brandname = Nike and CUSTOMER_NAME NOT NULL
What is the ViewHolder pattern?
When ListView cells that are scrolled off screen get re-used for new cells coming into view on the screen
What function for getting a database object must you call if you want to insert values?
getWriteableDatabase
In which version of Android was the Toolbar introduced?
5.0
What was the previous object that represented a navigation bar?
ActionBar
Where is a Toolbar placed in the Activity?
It depends on the Layout
What resource object is used to specify the layout of the Toolbar?
Menu
What resource object specifies what will be in the menu?
Item
What controls the order of the items in a menu?
The orderInCategory parameter
In which function should you inflate the menu?
onCreateOptionsMenu
Which function gets called in response to the user picking an item from the menu?
onOptionsItemSelected
What is the design pattern that is used for creating DialogBoxes?
Builder pattern
What function do you call to set the view of a Dialog box?
setView
In an AsyncTask, which function runs on a background thread?
doInBackground
In an AsyncTask, which function runs on the main GUI thread?
onProgressUpdate
In an XMLPullParser, which is the first event type that happens?
START_DOCUMENT
In an XMLPullParser, which event type corresponds to this tag: ?
END_TAG
In an XMLPullParser, which event type corresponds to “Hi” in this example: Hi ?
TEXT
Which function in Android returns the directory for opening files?
getFilesDir
Which permissions do you need to write to an External Folder?
WRITE_EXTERNAL_STORAGE
If a tablet has a screen size of 800x600 pixels, which folder name should you use to create a layout for this tablet?
layout-sw600dp
Which function should you use to inflate the view of a Fragment?
onAttach
What object is used to create a FragmentTransaction?
FragmentManager
What XML tag should you put in an XML layout to show where a Fragment should go?
framelayout