Please enable JavaScript.
Coggle requires JavaScript to display documents.
Android Basic (Intent and intent filter (Build an intent (Component name…
Android Basic
Intent and intent filter
Three fundamental use case:
- Start an activity
- Start a service
- Delivery a broadcast
Intent types:
- Explicit intent: specify the component to start by name
- Implicit intent: do not name a specific component
Build an intent
Component name
-
It's need with explicit intent,
If intent doesn't has component name, it's implicit intent.
-
Data
-
Method:
- setData
- setType
- setDataAndType
Category
- CATEGORY_BROWSABLE
- CATEGORY_LAUNCHER
-
Pending intent
grant permission to a foreign application to use the contained Intent as if it were executed from your app's own process.
Use case:
- executed when the user performs an action with your Notification
- executed when the user performs an action with your App Widge
- executed at a specified future time (ex AlarmManager)
Animation
-
Movement
Attribute to move obj horizontal row:<translate
android:fromXDelta
android:toXDelta />
set as a percentage of the size of the object that is being animated
-
-
-
-
Config and use widget
Size
-
-
Determining size:
wrap_content: wrap with it's content
match_parent: match with size of it's parent widget
-
gravity: gravity and layout_gravity
affect the position of a widget by moving it in a given direction
Padding and margin
Padding: space from the edge of the widget to the start of widget's content.
Margin: space outside of the widget that is left between
other widgets
Sub folder
Drawable:
drawable-hdpi, drawable-mdpi
drawable-xhdpi, drawable-xxhdpi
Layout
Size device:
layout-hdpi, layout-mdpi
layout-large, layout-xlarge
type rotate device:
layout-landscape, layout-portait
Dialog
simple pop-up dialog -> Dialog class (not support Android lifecycle, maybe crash app)
advanced feature -> Dialog Fragment
Steps:
- class extends DialogFragment
- initialize an object of the AlertDialog.Builder
- call builder.setMessage to set message to show in dialog
- call .setPositiveButton and .setNegativeButton method to set button
- override anonymous
DialogInterface.OnClickListener class to handle event touch of that button
- return object.create()
Context
-
handle to the system
Ex: resolving resources, obtaining access to databases and preferences
Layout
Linear Layout
Arrange:
- Horizontal row
- Vertical column
Relative Layout
-
Attribute arrange
Relative with parent
- android:layout_alignParentTop/Bottom/Left/Right
-
-
-
-
Fragment
Singleton of model layer
A class has only one instance
- It must be available to all throughout the life of the app at the same time
Lifecycle phases
Being created -> Starting -> Resuming -> Running -> Pausing -> Stopping -> Being Destroyed
OnCreate() -> onStart() -> onResume() -> onPause() -> onStop() -> onDestroy()