Mostly Android Flashcards

1
Q

What are some of the things stored in the android manifest?

A
  • Declares Package name
  • Activities
  • app name
  • launcher icon
  • permissions for the app
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

WHere are these defined: UI and Functionality

A

XML and Java Code (Activities)

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

Where in java code do you inflate the XML layout

A

In the onCreate method

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

With activity lifecycles, what are the four states?

A

Active, Visible, Hidden and Destroyed

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

in the activity stack, what’s the order? (Visible, Destroyed, Active and Hidden)

A

From top to bottom: Active-Visible-Hidden-Destroyed

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

When is the R class generated

A

When the application is compiled

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

What does the R class contain?

A

Contains access for all the resources in the res directory.

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

R.drawable.icon what is the datatype of this command?

A

A static Integer

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

How would you access Views? ie TextViews in XML

A

(TextView) findByView(R.id.textviewidname)

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

Can you find viewGroups the same way you find Views in java?

A

Yes, Viewgroups are just special types of View

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

how would you set up a button event listener with this code:
Button b =
(Button)findViewById(R.id.button1);

A
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
// do something
}
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How would you define onclick method in XML then access it from java

A

android:onClick=”onClick”
then java:

public void onclickSubmit(View v) {
// some code
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How would you launch another activity from any given activity

A

With intents

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

launching an activity requires an explicit or implicit intent?

A

Explicit

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

When passing through data to a new intent, which method would you use?

A

intent.putExtra(“key”, value)

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

when recieving an intent from another activity, which method do you use, and what variable would you pass it?

A

intent.getStringExtra(“variable_name”);

17
Q

What is an Implicit Intent? and an example

A

An implicit intent declares a general action to perform, which allows another app to handle the action. example: if you wanted to share text or images through social media, you would use an implicit intent to notify other apps that you have content to share

18
Q

Implicit intents contain which information

A

Action - to perform
Data - URI or MIME type
Category - which type of component that can handle the intent
Extras - any extra info

19
Q

What are the two types of context? Why would you use one over the other?

A

application context and activity context. Only use application context if it needs to live beyond your activity

20
Q

what ways can you get access to context

A

this, getApplicationContext() (in an activity)

21
Q

Explain the usefulness of the singleton pattern

A

if exactly one object is needed, as the singleton pattern restricts instantiation of a class to one instance

22
Q

Features of a singleton class

A

Private static Singleton;
Private constructor;
public static method that returns instance of itself

23
Q

Simple explaination of a Adapter pattern

A

Allows incompatible classes to work together by converting the interface of one class to match the other.

24
Q

How do Array Adapters work with List Views and a string array?

A

ArrayAdapters create a view for each array item, by calling toString() on each time and placing the result in a textView

25
Q

TextView, EditText… inherit from which class?

A

View, which inherits from Object

26
Q

Linear Layout, RelativeLayout… inherit from which class?

A

ViewGroup Class

27
Q

Can a View, contain a ViewGroup?

A

No, an ViewGroup is a special type of View

28
Q

You can draw to canvas, and to…?

A

A view

29
Q

You should draw to a view when?

A

Your graphics don’t need to change dynamically

30
Q

You should draw to a canvas when?

A

Your app needs to re-draw itself, such as in a game

31
Q

What is lean back mode used for. how to bring back the nav bar?

A

when users wont be interacting with the screen, such as when watching a movie. Navbar is brought back with a tap

32
Q

what is the immersive mode used for? how to bring back the system bars?

A

When users will be heavily interacting with the screen, bring back system bars by swiping in from edge

33
Q

What is immersive sticky mode for?

A

intended for games that require a lot of swiping. navbar appears transparent if swiping in from edge, but will disapear if the screen is tapped, or after a few seconds

34
Q

How would you keep track of multiple touches on the screen at once

A

By usiung a forloop that goes through the switch case, covering Event.down event.move and event.up
for every “pointer” on screnn

35
Q

When implimenting accelorometer, which methods do you need to register/initialize/unregister the listener

A

onCreate, onPause and onResume

36
Q

to listen for gestures, you will need to initialize what class>

A

The GestureDector class, then use gestureDetector.onTouchEvent(MotionEvent object) under onTouchEvent Overriden method

37
Q

by using GestureDetector,onGestureListener, you have to then override all the gesture types, what should you do if you only want to override one type of gesture?`

A
by Extending GestureDetector.SimpleOnGestureListener, then using that class 
gestureDector = new GestureDetector(context, new MySimpleGestureListener()) where MySimpleGestureListener() is the class you just created which extends SimpleOnGestureListener.
38
Q

what is an apk?

A

apk is the file format used by android for distribution