exam 2 Flashcards
What is an activity in android?
A single, focused thing that the user can do that creates a window that can be placed in the UI with setContent(View). Generates onCreate() and onPause() and almost always interacts with the user.
What are the permissions in an android application? Where do they go?
The following are permissions available on Android 6.0 and up: body sensors, calendar, camera, contacts, location, microphone, phone, SMS, and storage. the results of permission requests will be delivered to its onRequestPermissionsResult(int, String[], int[]) method.
Can you update GUI elements from any thread but the main thread? Can you create a separate GUI thread to handle the GUI elements? Can you update GUI element from a non-GUI thread, if so how?
Update GUI elements from any thread but main thread? - You can post a runnable which does the UI operation to main thread (multi-threading)
Create a separate GUI thread to handle GUI elements? - yes recommended so app does not time out
Update GUI from non-GUI thread? Yes, there are several ways to have non-UI threads request updates to the UI through the UI thread: Use runOnUiThread( ) method call, Use post( ) method call, Use the Handler framework, Use a Broadcasts and BroadcastReceiver (optionally with LocalBroadcastManager), or Use an AsyncTask’s onProgressUpdate( ) method
Can you run network operations (send / receive)on the GUI thread,or Main thread?
Both? Why or why not?
To avoid creating an unresponsive UI, don’t perform network operations on the UI thread. By default, Android 3.0 (API level 11) and higher requires you to perform network operations on a thread other than the main UI thread; if you don’t, a NetworkOnMainThreadException is thrown.
What is a view in android?
A view represents an area on the screen that is responsible for drawing and event handling. View is the base class for widgets which are used to create interactive UI components.
What is a layout in android
Invisible containers that hold views or view groups and define their layout properties. Defines the structure for an activity and can be set in the activities corresponding XML file.
Can you name a few layout types for android?
LinearLayout:
Lay out children in a single row or column
GridLayout:
Lay children out in multiple rows or columns
FrameLayout:
All children drawn as a stack - overlapping or not - to control use layout_gravity
RelativeLayout:
Positions children relative to edges or center of the RelativeLayout and also relative to other children
What is the resource folder, and what it is used for? What can be found in
resource folder?
The resources folder contains all of the resources that an Android project might need such as pictures, sounds, XML layouts, and certain values. It is used as a storage directory that can be accessed by the program when needed using a command like R.drawable.ajisafag Notice that you can’t include spaces, numbers, most symbols, and capital letters in the item name.
The sub directories within res typically include:
Drawable, layout, menu, mipmap, raw, values
What is the difference between overriding and overloading a method in java?
Overloading is used to increase readability and allows two or more methods in the same class to have the same name but with different parameters. Overriding is when a subclass of a class is has the same name and parameters but performs a different function than the class it extends
Which classes can you use for threading in android?
Mutex, Monitor, Interlocked, AutoResetEvent, Semaphore, Timer…
What is the build.gradle in gradle? What can you use it for?
Gradle is an advanced general purpose build management system based that supports the automatic download and configuration of dependencies or other libraries, this allows reusing the artifacts of existing build systems. A simple example is that you have to copy some files from one directory to another before the actual build process happens. A Gradle build script can do this.
How do you start an activity? What are the steps?
with an intent
What do you inherit from to create a GUI screen?
Extend an existing View class or subclass with your own class
The basic building unit of Android’s User Interface is called?
An activity
Where should the minimum SDK be listed, updated?
The values of the SDK methods are integrated into the tools system through inclusion in your module’s build.gradle file