2. Prerequisities
These concepts should all be (VERY?!) familiar :
- Arrays of basic objects and types
- Use and characteristics of ArrayList
- Polymorphism.
- Overriding of methods (e.g. toString())
- Wrapper Classes - Integer, String, Double etc.
3. Android - Why ?
● Android (from Google) will be our platform of choice.
● Approaching 1 BILLION Android enabled devices
currently in the world (September 2014)
● Currently has 51% of the world’s smartphone market
share
● The types of devices (cars, fridges etc etc) are growing
all the time.
4. Android - History
● Originally started in 2005 and bought by Google in 2007.
● Google then started the OHA (Open Handset Alliance) with
the idea of standardizing mobile software platform across
vendors (Samsung, HTC, Motorola etc etc)
● Currently on version 4.4 (nickname ‘Kit Kat’), previous
4.1, 4.2 & 4.3 were nicknamed ‘Jelly Bean’
● Alphabetically ordered sweet treats!
5. The Basics
● We’ll be using Android as our platform of choice.
● Android apps are written in Java. So we need basic
Java installed :)! For this course we’ll use Java 8
(latest)
● We also need Android SDK (extra on top of Java)
● We’ll be using Android Studio as our development tool
of choice. Can also use Eclipse ADT (can be moved to
Android Studio later)
8. Using Android Studio
● We could use Eclipse but it’s no longer in active
development.
● Android Studio is what Google are moving towards.
Currently at release candidaate level.
● When we create an App project in Android Studio or
Eclipse we see alot of stuff that “just gets created”.
So what are the basic key parts ?
10. Activites
● The basic building block of an app is an Activity.
● An Activity Java class that we write will ultimately
extend from android.app.Activity
● You can think of an Activity as a self-contained
“screen” of your app.
● Each Activity also has a corresponding layout file
(written in XML) - More later.
11. Resources
The very basic types of
resources you would
have would be :
● Images (different resolutions)
● Layout files for each Activity
(these are XML files)
● Strings, Styles and
Dimensions of components.
12. Activity Layouts
● Each Activity Java class has a corresponding layout
file (written in XML).
● Exists in the layout directory of resources.
● Can use the designer to generate this XML for us.
● Can also do it similar to how we did it in Swing, but
less popular in general (ViewGroups)
13. The Manifest File
● Every Android app must have an
AndroidManifest.xml file which is the “glue”
that brings everything together to form an app.
● It names the package for the Android
application
package="com.example.simon.myfirstapp"
● Also says which code files (including Java) are
behind each screen (Activity) in the app.
14. Start of the Manifest File
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
These are the icon, label and theme
of your app and are picked up from
the Resources (res directory)
@style automatically links to
res/values/styles.xml
@string automatically links to
res/values/strings.xml
@drawable
automatically links to
the relevant
res/drawable
directory
15. android:label
android:icon
The font, colour, style, spacing
(i.e. “The look”) of the app is
controlled by
android:style
(in this case AppTheme in style.xml)
This is where your Activity runs.
Here we see MainActivity.java
16. Activities in Manifest File
● Activities must also be defined in the manifest
file.
<activity
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Reference to the
Java file where the
Activity is
implemented.
17. What is <intent-filter> ?
● As previously mentioned each Activity is
capable of being launched as a “self-contained”
unit.
● An <intent-filter> defines where an Activity
can be launched from. (i.e. Where you “intend” it to
be launched from)
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
18. <intent-filter>
The <action> element specifies that this is the "main" entry
point to the application. (Like main in regular Java)
The <category> element specifies that this activity should be
listed in the system's application launcher (to allow users to
launch this activity).
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
19. A First Basic App
Key Parts of an Android App are :
Activity (Java) / Activity Layout (XML)
Manifest
Resource Directories
Next Week :
Activity Lifecycle & GUI Event Handling