Survey							
                            
		                
		                * Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
OSLL
Hello Android
Romanikhin Vasily
1
Table of content
●
About Adroid;
●
Android Architecture;
●
Application Fundamentals
●
Activity, Service, ContentProvider, BroadcastReceiver, Intent classes ●
Application Resources
●
User Interface
●
Software for developing
●
Practice
2
What is Android?
●
●
●
●
Android Inc.
Open Handset
Alliance (OHA)
September 23,
2008
October 21, 2008
3
Android Architecture
4
The project structure
MyProject/
src/
MyActivity.java
res/
drawable/
icon.png
layout/
main.xml
values/
strings.xml
raw/
libs/
...
assets/
...
gen/
R.java
AndroidManifest.xml
✔
src/
✔
res/
✔
drawable/
✔
layout/
✔
values/
✔
gen/
✔
AndroidManifest.xml
5
Application Fundamentals
●
Application Components:
●
Activities
●
Services
●
Broadcast receivers
●
Content providers
●
~ Intent
●
~ Bundle
6
Activity
http://developer.android.com/reference/android/app/Activity.html
●
●
●
●
●
●
●
protected void onCreate(Bundle savedInstanceState);
protected void onStart();
protected void onRestart();
protected void onResume();
protected void onPause();
protected void onStop();
protected void onDestroy();
7
Service
http://developer.android.com/reference/android/app/Service.html
startService(...)
● stopService(...)
●
bindService(...)
● unbindService(...)
●
8
Implementation Service
example
9
BroadcastReceiver
http://developer.android.com/reference/android/content/BroadcastReceiver.ht
ml
●
●
●
●
public void onReceive(Context context, Intent intent) {/* Actions … */}
Life cycle: if return from onReceive()  system kill it
Before using BR you must register it (dynamically – in code; or statically – in AndroidManifest.xml)
The most often used with Service
10
ContentProvider
http://developer.android.com/reference/android/content/ContentProvider.html
The primary methods that need to be implemented are:
●
●
●
●
●
●
onCreate() which is called to initialize the provider
query(Uri, String[], String, String[], String) which returns data to the caller
insert(Uri, ContentValues) which inserts new data into the content provider
update(Uri, ContentValues, String, String[]) which updates existing data in the content provider
delete(Uri, String, String[]) which deletes data from the content provider
getType(Uri) which returns the MIME type of data in the content provider
Why is it need?
● See also ContentResolver, SQLiteOpenHanhler,
Cursor, ManagedCursor.
●
11
AndroidManifest.xml
http://developer.android.com/guide/topics/manifest/manifest-intro.html
12
AndroidManifest.xml
<application>
<activity/>
<service/>
<receiver/>
<provider/>
</application>
13
Application Resourses
res/
MyProject/
src/
MyActivity.java
res/
drawable/
icon.png
layout/
main.xml
values/
strings.xml
raw/
gen/
R.java
●
anim/
●
color/
●
drawable/
●
layout/
●
menu/
●
values/
●
xml/
●
raw
14
Application Resources
res/
drawable/
icon.png
background.png
drawable-hdpi/
icon.png
background.png
15
Accessing Resources
/res/values/strings.xml
16
User Interface
●
Runtime (programmically)
●
Xml layout file (ex: res/layout/main.xml)
●
View
●
View group
17
Example layout file
18
Required software
●
JDK >= 1.5 ●
Android SDK (http://developer.android.com/sdk/index.html)
●
Adding Platforms and Other Components
●
Android NDK (http://developer.android.com/sdk/ndk/index.html)
●
Ant >= 1.7
Eclipse (http://www.eclipse.org/downloads/)
ADT (http://developer.android.com/sdk/eclipseadt.html)
http://osll.spb.ru/projects/geo2tag/wiki/_android_hello_
19
Adding Platforms and Other
Components
●
androidsdk<...>/tools/android (Linux or Mac)
●
SDK Manager.exe (Windows)
Result:
●
AVDs
●
USB Drivers
●
...
20
Troubles
●
Problems with jdk (not use openjdk)
●
ia32libs (aptget install ia32libs)
●
Developing on a Device
●
●
USB Vendor IDs (for Linux or Mac) Device ????  http://itobzor.com/blog/aliev/pravilnaya
nastroikaubuntudlyarazrabotkipodandroidili
reshaemproblemunopermissio
USB Driver (for Windows)
21
Practice
●
ExampleButton
●
ExampleButtonExt
●
ExStackActivity
●
ExService
●
ExBroadcastReceiver
●
ExContentProvider
22
What is remained...
●
●
Storage data ●
Internal, External Storage
●
DB
●
SharedPreferences.
Designing for Performance http://developer.android.com/guide/practices/desi
gn/performance.html
23
●
Questions... ???
●
Thanks!
24