Chapter 5 Flashcards
manifest
xml file containing metadata that describes your application to the android OS. every activity in an application must be declared in the manifest so that the OS can access it.
.CheatActivity why (.)?
dot tells the OS that this activity’s class is in the package specified in the package attribute in the manifest element at the top of the file.
how to start another activity (1)?
call the Activity method:
public void startActivity(Intent intent)
how startActivity(Intent intent) works:
when startActivity(...) is called on by the activity, this call is sent to the OS. it is sent to a part of the OS called the ActivityManager.
ActivityManager
part of the OS and receives startActivity(…) calls. Creates the Activity instance and calls its onCreate(…) method.
Intent
knows which Activity to start. Object that a component can use to communicate with the OS
component examples:
services, broadcast receivers, activities, and content providers.
public Intent(Context packageContext, Class cls)
Class object specifies the activity that the ActivityManager should start. the Context object tells the ActivityManager which package the Class object can be found in.
When an activity in your application wants to start an activity in another application, you create an _______.
implicit intent (more in chapter 21).
extra (intent)
Extras are arbitrary data that the calling activity can include with an intent. the OS forwards the intent to the recipient activity, which can then access the extra and retrieve the data.
extra is structured as a key-value pair(t/f)
True
public Intent putExtra(String name, boolean value)
comes in many flavors, but it always has two arguments. String key and second argument is the value, whose type will vary.
public boolean getBooleanExtra(String name, boolean defaultValue)
first argument: name of the extra. Second argument: default answer if the key is not found.