Android Programming: Setup For Android Development
Android Programming: Setup For Android Development
Android Development
Based on material from Adam Champion, Xinfeng Li, C. Horstmann [1], J. Bloch [2],
C. Collins et al. [4], M.L. Sichitiu (NCSU), V. Janjic (Imperial College London),
CSE 2221 (OSU), and other sources
1
Outline
Introduction to Android
Getting Started
Android Programming
Introduction to Android
Popular mobile device
OS: 52% of U.S.
smartphone market [8]
Developed by Open
Handset Alliance, led by
Google
Google claims 900,000
Android device
activations [9]
Source: [8]
3
What is Android
Android is an operating system for mobile devices such
as smartphones and tablet computers. It is developed by
the Open Handset Alliance led by Google.
Android has beaten Apple iOS, being the leading mobile
operating system from first quarter of 2011
Version: Android 1.0, 1.1 to 1.5 (Cupcake), 1.6 (Donut),
2.0/2.1 (Eclair), 2.2 (Froyo), 2.3 (Gingerbread), to 3.0
(Honeycomb), 4.0 (Ice Cream Sandwich), 5.0 (Lollipop)
Android Architecture
Outline
Introduction to Android
Getting Started
Android Programming
Open /Applications/Utilities/Terminal.app
Type javac at command line
Install Java when prompt appears
Linux:
Type sudo aptget install defaultjdk at command line
(Debian, Ubuntu)
Other distributions: consult distributions documentation
7
Install!
Install!
10
11
Settings
Outline
Introduction to Android
Getting Started
Android Programming
13
(not
App Manifest
Every Android app must include an
AndroidManifest.xml file describing functionality
The manifest specifies:
17
Activity Lifecycle
key building
block of Android apps
Extend Activity class,
override onCreate(),
onPause(), onResume()
methods
Dalvik VM can stop any
Activity without warning,
so saving state is important!
Activities need to be
responsive, otherwise
Android shows user App
Not Responsive warning:
Activity:
Source: [12]
23
24
25
26
27
@Override
protected void onResume()
{
super.onResume();
registerReceiver(mReceiver,
mIntentFilter);
}
@Override
protected void onPause()
{
super.onPause();
unregisterReceiver(mReceiver
);
}
28
29
User Interface
Updating UI in code
private void setTextView(String
str)
{
TextView tv = (TextView)
findViewById(R.id.textview);
tv.setMovementMethod(new
ScrollingMovementMethod());
tv.setText(str);
}
UI Layout (XML)
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/androi
d"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/button"
android:text="@string/button_text"/>
<TextView
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/ap_list"
tools:context=".WiFiActivity"
android:textStyle="bold"
android:gravity="center">
</TextView>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".WiFiActivity"
android:id="@+id/textview"
android:scrollbars="vertical">
</TextView>
</LinearLayout>
30
31
Thank You
Any questions?
35
References (1)
1.
2.
3.
4.
5.
6.
7.
8.
9.
References (2)
10.
11.
12.
13.
14.
15.
http://bcs.wiley.com/he-bcs/Books?action=index&itemId=1118087887&bcsId=7006
B. Goetz, T. Peierls, J. Bloch, J. Bowbeer, D. Holmes, and D. Lea, Java Concurrency in
Practice, Addison-Wesley, 2006, online at
http://proquest.safaribooksonline.com/book/programming/java/0321349601
https://developer.android.com/guide/components/activities.html
https://developer.android.com/guide/topics/ui/declaring-layout.html#CommonLayouts
https://cloud.genymotion.com/page/doc/#collapse4
http://blog.zeezonline.com/2013/11/install-google-play-on-genymotion-2-0/
37