Android Development Flashcards
What are the 4 types of app components?
Activities.
Services.
Broadcast receivers.
Content providers.
What is an Activity lifecycle?
https://developer.android.com/reference/android/app/Activity.html
Launched -> onCreate -> onStart -> onResueme -> Running -> onPause -> onStop
onPause -> onResume
onStop -> Killed or onStop -> onRestart
What is an Intent?
A messaging object you can use to request an action from another app component.
What are the three fundamental use cases of an intent?
- starting an activity
- starting a service
- delivering a broadcast
Should an implicit intent be used when starting a service?
No
Why should you use an explicit intent to start a service?
Security reasons, and if an implicit intent is used, your app doesn’t have control of which service will respond to the intent. (API 21+) throws exception if using an implicit intent on call ‘bindService()’
What are the main component of building an Intent?
Component name, Action, Data, Category, Extras, Flags
How do components receive intents?
Declaring one or more intent filters for each of the app components with an element in the manifest file.
Which three tests must a intent filter pass for implicit intent to use that component?
Action test, Category test, Data test
Can you declare multiple per component?
Yes
Which object has a set of query methods that will return all components that accept a particular intents? (by checking components )
PackageManager
What class serves ass the entry point for an app’s interaction with the user?
Activity class
Where must you declare activities that will be used in your application?
in the manifest file.
What is the only required attribute for declaring an activity in the manifest?
android:name attribute
Which Activity callback method is called when the system first creates the activity?
onCreate()