exam 2 Flashcards

1
Q

What is an activity in android?

A

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.

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

What are the permissions in an android application? Where do they go?

A

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.

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

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?

A

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

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

Can you run network operations (send / receive)on the GUI thread,or Main thread?
Both? Why or why not?

A

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.

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

What is a view in android?

A

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.

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

What is a layout in android

A

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.

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

Can you name a few layout types for android?

A

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

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

What is the resource folder, and what it is used for? What can be found in
resource folder?

A

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

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

What is the difference between overriding and overloading a method in java?

A
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which classes can you use for threading in android?

A

Mutex, Monitor, Interlocked, AutoResetEvent, Semaphore, Timer…

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

What is the build.gradle in gradle? What can you use it for?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you start an activity? What are the steps?

A

with an intent

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

What do you inherit from to create a GUI screen?

A

Extend an existing View class or subclass with your own class

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

The basic building unit of Android’s User Interface is called?

A

An activity

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

Where should the minimum SDK be listed, updated?

A

The values of the SDK methods are integrated into the tools system through inclusion in your module’s build.gradle file

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

What do you put in the AndroidManifest.xml file?

A

Package, Version, Permission, Application

17
Q

Which directory, path from main directory, does the XML layout files reside?

A

/ProjectName/app/src/main/res/layout

18
Q

Semaphores – What are they, how are they used in Android.

A

Conceptually, a semaphore maintains a set of permits. However, no actual permit objects are used; the Semaphore just keeps a count of the number available and acts accordingly. Semaphores are often used to restrict the number of threads than can access some (physical or logical) resource.

19
Q

20.Handler – What it is, what it does and the code to go with it.

A
Handler is msg distribution object that sends and processes msgs and Runnable objects associated with a thread's MessageQueue. Each Handler instance is associated with a single thread and that thread's message queue.
There are two main uses for a Handler: (1) to schedule messages and runnables to be executed as some point in the future; and (2) to enqueue an action to be performed on a different thread than your own.
Handler myHandler = new Handler() { 
         public void handleMessage(Message msg) {  
              switch (msg.what) {  
                   case TestHandler.GUIUPDATEIDENTIFIER:  
                        myBounceView.invalidate(); 
                        break;  
              }  
              super.handleMessage(msg);  
         }  
    };