Android Application Framework

38
Danny Fürniß, 28.10..2012, 1 Programmierung von Apps Android Application Framework

description

Unterlage zur Android Vorlesung "Programmierung von Apps" an der Hochschule Karlsruhe. Die Studierenden kennen die Bausteine des Android Application Framework und verstehen, wie sich daraus eine Android App zusammenbauen lässt.

Transcript of Android Application Framework

Page 1: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

1

Programmierungvon Apps

Android Application Framework

Page 2: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

2

Die Studierenden kennen die Bausteine des

Android Application Framework und verstehen, wie sich daraus eine Android App zusammen-

bauen lässt.

Page 3: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

3

AndroidApplication Framework

Bildquelle: http://s31.a2zinc.net/clients/ezlandscape/congress12/public/Content.aspx?ID=3577&sortMenu=104000

Page 4: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

4

Bildquelle: http://developer.android.com/guide/basics/what-is-android.html

BAUSTEINE

Page 5: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

5

Woraus besteht eine Android App?

Bildquelle: http://ecom-software.com/2114-android-mega-games-pack-87-games-july-2011-pdu.html

Page 6: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

6

Kontext Sicht

Page 7: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

7

Black Box Sicht

Page 8: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

8

Black Box Sicht

AndroidManifest.xml

Activities/Services

BroadcastReceivers

ContentProviders

Page 9: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

9

Black Box Sicht

AndroidManifest.xml

Activities/Services

BroadcastReceivers

ContentProviders

Page 10: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

10

AndroidManifest.xml<manifest

package=„com.dfuerniss.app“<uses-permission><uses-feature><supports-screens><application>

<activitiy><service><receiver><provider>

<uses-sdk>…

Page 11: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

11

<manifest>

packagexmlns:androidversionCodeversionNameinstallLocation…

http://developer.android.com/guide/topics/manifest/manifest‐intro.html

Page 12: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

12

<uses-permission>

http://developer.android.com/reference/android/Manifest.permission.html

android.permission.INTERNETandroid.permission.ACCESS_NETWORK_STATEandroid.permission.USE_CREDENTIALSandroid.permission.AUTHENTICATE_ACCOUNTSandroid.permission.READ_CONTACTSandroid.permission.WRITE_CONTACTSandroid.permission.WRITE_EXTERNAL_STORAGE…

Page 13: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

13

Application Object

Klassepublic class PVAUebungApplication extends application…

AndroidManifest.xml<application android:name=„PVAUebungApplication“…

Page 14: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

14

Resources

Page 15: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

15

Resource Types

Quelle: http://developer.android.com/guide/topics/resources/providing-resources.html

res/animatorres/animres/color

res/drawableres/layoutres/menures/rawres/valuesres/xml

Page 16: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

16

Resource Qualifiers

Quelle: http://developer.android.com/guide/topics/resources/providing-resources.html

Language/Region

Screen‐Size

Screen‐Orientation

Platform‐Version

etc.

/values‐en‐rUS

/layout‐xlarge

/layout‐land

/color‐v13

etc.

Page 17: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

17

R.java (generated)public final class R {public static final class color {public static final int background_gradient_66=0x7f060001;public static final int bar_color=0x7f060003;

}public static final class dimen {public static final int text_size_large=0x7f070004;public static final int text_size_small=0x7f070002;

}public static final class drawable {public static final int chart_bar_gradient_co2=0x7f020001;public static final int chart_bar_gradient_gp=0x7f020002;public static final int chart_bar_gradient_ht=0x7f020003;public static final int chart_bar_gradient_nt=0x7f020004;

}}

Page 18: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

18

Activities

Page 19: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

19

Siehe auch „Learning Android“, S. 29

ActivityLifecycle

Page 20: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

20

onSaveInstanceState()

onCreate(Bundle savedInstanceState)

Page 21: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

21

Fragments

Page 22: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

22

FragmentLifecycle

Page 23: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

23

Loaders

Page 24: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

24

Intents

Page 25: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

25

Explizite Intents

Page 26: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

26

Implizite Intents

Page 27: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

27

PendingIntent

Intent intent = new Intent(context, DashboardActivity.class)

PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent,

PendingIntent.FLAG_ONE_SHOT)

Page 28: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

28

startActivityForResult()

Page 29: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

29

Services

Page 30: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

30

Services

Threading berücksichtigen!

Page 31: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

31

Local Service

Page 32: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

32

Remote Service

Page 33: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

33

Intent Service

public class FetchDataService extends IntentService

Page 34: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

34

Broadcast Receivers

Page 35: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

35

Konfiguration über Intent-Filter

Permission ACCESS_NETWORK_STATE notwendig

Page 36: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

36

Content Providers

Page 37: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

37

ContentProvider

Page 38: Android Application Framework

Dann

y Für

niß,

28.

10..2

012,

38

Portions of this presentation are modifications based on work created and shared by Google and used according

to terms described in the Creative Commons 3.0

Attribution License.