5. Android is built on top of Linux kernel.
Android uses a number of libraries to perform various functionalities.
6. Android is built on top of Linux kernel.
Android uses a number of libraries to perform various functionalities.
Just like the Java Virtual Machine in our computers, Android has its
own Dalvik Virtual Machine optimized for itself.
7. Android is built on top of Linux kernel.
Android uses a number of libraries to perform various functionalities.
Just like the Java Virtual Machine in our computers, Android has its
own Dalvik Virtual Machine optimized for itself.
Higher-level services to applications in the form of Java classes:
Application Framework.
8. Android is built on top of Linux kernel.
Android uses a number of libraries to perform various functionalities.
Just like the Java Virtual Machine in our computers, Android has its
own Dalvik Virtual Machine optimized for itself.
Higher-level services to applications in the form of Java classes:
Application Framework.
We will write applications to be installed on the Application layer only.
10. Android’s defined tags
Introduction to
xml
Used to define some of
the resources
- Layouts
- Strings
Used in Android
Manifest
Preferred way for
defining UI elements
- Separation of
code
12. LO
AU
YT
Eclipse has a great UI creator
- Generates all the xml for you
Composed of View objects
Can be specified for portrait or
landscape
- Different designs for different
orientation.
13. VIEWS
A layout/activity is composed of
Views and ViewGroups.
View is something that is visible.
Examples:
-
-
-
-
TextViews,
Buttons,
TimePicker,
DatePicker
14. VIEWS
3 ways to declare width and height
a.
b.
c.
fill_parent
wrap_content
match_parent
<Button
android:id = “@+id/button”
android:layout_width = “fill_parent”
android:layout_height = “wrap_content”
android:text = “Button”/>
{
DO NOT FORGET
TO DEFINE US
17. FrameLayout
4
One or more View can be
grouped into a ViewGroup
RelativeLayout
3
This is the <body> to your
view.
LinearLayout
2
ViewGroups
1
TableLayout
5
ScrollView, etc.
18. Each layout has something
unique to it.
Each layout has a purpose!
19. LinearLayout
Declaring the XML namespace (done
in the 1st ViewGroup)
<LinearLayout
xmlns:android=“http://schemas.android.com/apk/res/
android”
android:layout_width= “match_parent”
android:layout_height= “match_parent”
android:orientation= “vertical”>
… (TextViews, Buttons etc.)
</LinearLayout>
Unique for this ViewGroup
a. Vertical
b. Horizontal
20. RelativeLayout
Does not have any android:orientation.
Affects the layouts inside it
Views are arranged according to references.
26. ENTS
<a href= “target”>page 2</a>
Intent ~ Redirecting !
Intent is used to call into android's drivers,
other applications as well.
Powerful inter/intra application messagepassing framework.
While working with intents we also have to
work with the
Android Manifest
27. Android Manifest
Presents essential information
about the application to the
Android system
Information the system must have before it
can run any of the application's code.
29. Manifest
Name of the Java package for the
application.
It describes the components of
the application
the activities, services, broadcast receivers, and
content providers.
30. Manifest
It declares which permissions the
application must have in order to
access protected parts of the API and
interact with other applications.
It declares the minimum level of the
Android API that the application
requires … and much more.
31. MODIFICATION IN ANDROID MANIFEST
Declares an activity (an Activity
subclass) that implements part of the
application’s visual user interface.
<activity android:name=".OtherClass">
<intent-filter>
<action android:name="android.intent.action.NAME"/>
<category
android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
The types of intents that an app can
respond to
Adds an action to an intent filter
Adds a category name to an intent
filter
32. In MainActivity
Intent i = new Intent(MainActivity.this,
OtherClass.class); // Instantiating the intent
class
i.putExtra(“name”, value); // values to be sent
startActivity(i); // Starting the intent
In OtherClass
Intent i = getIntent(); //getting the intent
object
String name = i.getStringExtra(“name”); //
getting value from passed intent
Intents
33. HAVE YOU EVER WONDERED
WHAT HAPPENS WHEN YOU
PRESS THE BACK BUTTON/
HOME BUTTON ON ANDROID?
35. Activity
Life
Cycle
onCreate() :
instantiate views, setup
references, implement
listeners.
onPause() :
save data/state in the
application.
onResume() :
can be used to load the
saved state, is always
called when the application
comes into view.