| Day | hours |
|---|---|
| 2014-01-21 | 1 |
| 2014-01-22 | 1 |
| 2014-01-23 | 1 |
| 2014-01-25 | 2 |
| 2014-01-31 | 1 |
| 2014-02-01 | 2 |
| 2014-02-06 | 2 |
metskem@athena ~ $ telnet localhost 5554
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK
help
Android console command help:
help|h|? print a list of commands
event simulate hardware events
geo Geo-location commands
gsm GSM related commands
cdma CDMA related commands
kill kill the emulator instance
network manage network settings
power power related commands
quit|exit quit control session
redir manage port redirections
sms SMS related commands
avd control virtual device execution
window manage emulator window
qemu QEMU-specific commands
sensor manage emulator sensors
try 'help <command>' for command-specific help
OK
, for example:
adb -s emulator-5554 logcat WikiNotes:I *:S
Four main building blocks in Android :
Non code (resource) files
Activity
The Activity Lifecycle:
-- onRestart() , do specific stuff required after activity was stopped
-- onStart() , loading persistent application state
-- onResume() , start foreground-only actions
-- onPause() , shutdown foreground-only actions, save persistent stat
-- onStop() , cache state (may not be called when Android kills the activity)
-- onDestroy() , release activity resources (may not be called when Android kills the activity)
Activities are created by creating Intents, and passing these Intents to startActivity() or startActivityForResult() . Started activity can set the result with Activity.setResult().
AndroidManifest.xml
Contains:
Intents
Intent is a data structure that represents:
Intent fields:
Activity is a subclass of Context, so you can for example use new Intent(MyActivity.this, SecondActivity.class);
Two ways of Intent resolution:
Implicit Intent resolution uses the following data of the Intent:
Installed apps have intent-filters defined in their AndroidManifest.xml.
These filters can specify things like data, action, category and so on. If they want to react to implicit intents, they always have to specify the intent-filter category.DEFAULT.
If you want to know what's on your device (for example all intent filters) :
adb shell dumpsys package
Permissions
Android uses permissions to protect Resources, data and operations.
Applications can define their own permissions to protect their own resources (other apps are required to have those permissions). (permission tag) And applications can define the permissions they use themselves (uses-permission).
There are application-level permissions and component-level permissions, the latter take precedence.
And we have :
Fragments
Introduced in Android 3.0 to better support larger screens (Tablets).
Fragments represent a portion of a UI within an Activity => multi-pane activities.
A single Fragment can be used across multiple activities.
The lifecycle of a Fragment is coordinated with the lifecycle of an Activity, but they also have their own lifecycle callbacks.
Fragment lifecycle states :
Fragment callbacks :
Statically add Fragment to Activity by specifying them in the layout file, or programmatically using the FragmentManager.
User Interfaces
The View is the place and the means to exchange information between the user and the Application.
View is the key building block. It occupies a rectangular space on the screen, they are responsible for drawing themselves and handling events.
Predefined Views:
Common View operations:
View Listener Interfaces:
Displaying Views
Views are organized as a tree, Views with child Views Android walks the View tree three times:
ViewGroups
ViewGroups are invisable that contain other Views , use it to group/organize Views and ViewGroups.
Predefined ViewGroups:
Layouts are ViewGroups.
LinearLayout - less or more fixed order RelativeLayout - layout is relative TableLayout - child views are arranged in rows and columns GridView - 2-dimensional scrollable View
Menus and ActionBar
Activities support Menus (a quick way to access important functions). Activities can add items to the menu.
Menu types:
Creating menus getMenuInflater() , and inflate with a context menu
ActionBar, similar to desktop applications, quick access to common operations . Multiple Activities and Fragments can add items there.
Dialogs: