Android 101 workshop

30
Android 101 workshop Getting started with Android development

description

Slides for my Android 101 session at the 2012 Berlin DevFest.

Transcript of Android 101 workshop

Page 1: Android 101 workshop

Android 101 workshopGetting started with Android development

Page 2: Android 101 workshop

Benjamin Weisshttp://gplus.to/keyboardsurferTwitter: @keyboardsurfer

Senior Software Developerat ImmobilienScout24

Organizer: GDG Android in Berlin

Co-Organizer:● Global Android Dev Camp● GTUG Community Weekend● Google I/O Extended Berlin 2012● DevFest Berlin 2012

Page 3: Android 101 workshop

Agenda

● The Setup● Hello Android● AndroidManifest.xml● Intents● Views● Respond to user-interaction● Using libraries● Hands on

Page 4: Android 101 workshop

The Setup

Platform of choice

LinuxMacWindowsAndroid

Page 5: Android 101 workshop

The Setup

Development Environment

http://eclipse.org

https://www.jetbrains.com/idea

AIDEhttps://play.google.com/store/apps/details?id=com.aide.ui

Page 6: Android 101 workshop

The Setup

Android SDK

https://developer.android.com/sdk/index.html

Page 7: Android 101 workshop

Hello Android

Page 8: Android 101 workshop

AndroidManifest.xml

https://developer.android.com/guide/topics/manifest/

manifest-intro.html

Page 9: Android 101 workshop

AndroidManifest.xml<manifest>

<uses-permission /> <permission /> <permission-tree /> <permission-group /> <instrumentation /> <uses-sdk /> <uses-configuration /> <uses-feature /> <supports-screens /> <compatible-screens /> <supports-gl-texture />

<application>

<activity> <intent-filter> <action /> <category /> <data /> </intent-filter> <meta-data /> </activity>

<activity-alias> <intent-filter> . . . </intent-filter> <meta-data /> </activity-alias>

<service> <intent-filter> . . . </intent-filter> <meta-data/> </service>

<receiver> <intent-filter> . . . </intent-filter> <meta-data /> </receiver>

<provider> <grant-uri-permission /> <meta-data /> </provider>

<uses-library />

</application>

</manifest>

Page 10: Android 101 workshop

AndroidManifest.xml<manifest>

<uses-permission /> <permission /> <permission-tree /> <permission-group /> <instrumentation /> <uses-sdk /> <uses-configuration /> <uses-feature /> <supports-screens /> <compatible-screens /> <supports-gl-texture />

<application>

<activity> <intent-filter> <action /> <category /> <data /> </intent-filter> <meta-data /> </activity>

<activity-alias> <intent-filter> . . . </intent-filter> <meta-data /> </activity-alias>

<service> <intent-filter> . . . </intent-filter> <meta-data/> </service>

<receiver> <intent-filter> . . . </intent-filter> <meta-data /> </receiver>

<provider> <grant-uri-permission /> <meta-data /> </provider>

<uses-library />

</application>

</manifest>

<manifest xmlns:android= "http://schemas.android.com/apk/res/android" android:installLocation="auto" package="my.package.name" android:versionCode="42" android:versionName="theLifeTheUniverseAndEverything-Beta">

Page 11: Android 101 workshop

AndroidManifest.xml<manifest>

<uses-permission /> <permission /> <permission-tree /> <permission-group /> <instrumentation /> <uses-sdk /> <uses-configuration /> <uses-feature /> <supports-screens /> <compatible-screens /> <supports-gl-texture />

<application>

<activity> <intent-filter> <action /> <category /> <data /> </intent-filter> <meta-data /> </activity>

<activity-alias> <intent-filter> . . . </intent-filter> <meta-data /> </activity-alias>

<service> <intent-filter> . . . </intent-filter> <meta-data/> </service>

<receiver> <intent-filter> . . . </intent-filter> <meta-data /> </receiver>

<provider> <grant-uri-permission /> <meta-data /> </provider>

<uses-library />

</application>

</manifest>

<uses-permission />

Page 12: Android 101 workshop

AndroidManifest.xml<manifest>

<uses-permission /> <permission /> <permission-tree /> <permission-group /> <instrumentation /> <uses-sdk /> <uses-configuration /> <uses-feature /> <supports-screens /> <compatible-screens /> <supports-gl-texture />

<application>

<activity> <intent-filter> <action /> <category /> <data /> </intent-filter> <meta-data /> </activity>

<activity-alias> <intent-filter> . . . </intent-filter> <meta-data /> </activity-alias>

<service> <intent-filter> . . . </intent-filter> <meta-data/> </service>

<receiver> <intent-filter> . . . </intent-filter> <meta-data /> </receiver>

<provider> <grant-uri-permission /> <meta-data /> </provider>

<uses-library />

</application>

</manifest>

<uses-permission /> !

Page 13: Android 101 workshop

AndroidManifest.xml<manifest>

<uses-permission /> <permission /> <permission-tree /> <permission-group /> <instrumentation /> <uses-sdk /> <uses-configuration /> <uses-feature /> <supports-screens /> <compatible-screens /> <supports-gl-texture />

<application>

<activity> <intent-filter> <action /> <category /> <data /> </intent-filter> <meta-data /> </activity>

<activity-alias> <intent-filter> . . . </intent-filter> <meta-data /> </activity-alias>

<service> <intent-filter> . . . </intent-filter> <meta-data/> </service>

<receiver> <intent-filter> . . . </intent-filter> <meta-data /> </receiver>

<provider> <grant-uri-permission /> <meta-data /> </provider>

<uses-library />

</application>

</manifest>

<activity> <intent-filter> <action /> <category /> <data /> </intent-filter> <meta-data /></activity>

Page 14: Android 101 workshop

AndroidManifest.xml<manifest>

<uses-permission /> <permission /> <permission-tree /> <permission-group /> <instrumentation /> <uses-sdk /> <uses-configuration /> <uses-feature /> <supports-screens /> <compatible-screens /> <supports-gl-texture />

<application>

<activity> <intent-filter> <action /> <category /> <data /> </intent-filter> <meta-data /> </activity>

<activity-alias> <intent-filter> . . . </intent-filter> <meta-data /> </activity-alias>

<service> <intent-filter> . . . </intent-filter> <meta-data/> </service>

<receiver> <intent-filter> . . . </intent-filter> <meta-data /> </receiver>

<provider> <grant-uri-permission /> <meta-data /> </provider>

<uses-library />

</application>

</manifest>

<activity> <intent-filter> <action /> <category /> <data /> </intent-filter> <meta-data /></activity>

!

Page 17: Android 101 workshop

Intent

An Intent provides a facility for performing late runtime binding between the code in different applications.Its most significant use is in the launching of activities, where it can be thought of as the glue between activities.It is basically a passive data structure holding an abstract description of an action to be performed.

Page 18: Android 101 workshop

Intent

An Intent provides a facility for performing late runtime binding between the code in different applications.Its most significant use is in the launching of activities, where it can be thought of as the glue between activities.It is basically a passive data structure holding an abstract description of an action to be performed.

Page 19: Android 101 workshop

Intent

Page 20: Android 101 workshop

Views<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width ="fill_parent" android:layout_height ="fill_parent" android:paddingLeft ="16dp" android:paddingRight ="16dp" android:orientation ="vertical" > <EditText android:layout_width ="fill_parent" android:layout_height ="wrap_content" android:hint="@string/to" /> <EditText android:layout_width ="fill_parent" android:layout_height ="wrap_content" android:hint="@string/subject" /> <EditText android:layout_width ="fill_parent" android:layout_height ="0dp" android:layout_weight ="1" android:gravity ="top" android:hint="@string/message" /> <Button android:layout_width ="100dp" android:layout_height ="wrap_content" android:layout_gravity ="right" android:text="@string/send" /></LinearLayout>

Page 21: Android 101 workshop

Views

public class OneOhOneDemo extends Activity{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); }...}

Page 22: Android 101 workshop

Views

Page 23: Android 101 workshop

User interaction

someView.setOnClickListener(new OnClickListener() { public void onClick(View view) { //handle event } });

Page 24: Android 101 workshop

Libraries

Page 25: Android 101 workshop

Libraries

● Support Library● android-json-rpc● oauth-signpost● greenDAO● GSON● ...

Page 26: Android 101 workshop

Important links

https://developer.android.comhttps://developer.android.com/sdk/index.htmlhttps://developer.android.com/guide/components/index.htmlhttps://developer.android.com/training/basics/firstapp/index.html

https://stackoverflow.com

http://www.openintents.org/en/libraries

Page 27: Android 101 workshop

Questions

Page 28: Android 101 workshop

Get your keyboards clicking!

Page 29: Android 101 workshop

Thank youBenjamin Weisshttp://gplus.to/keyboardsurferTwitter: @keyboardsurfer

Page 30: Android 101 workshop

Image Sources● http://www.devfest.info/images/vhabig.png● https://en.wikipedia.org/wiki/Linux● https://en.wikipedia.org/wiki/Windows● https://en.wikipedia.org/wiki/Windows● https://d.android.com● http://www.eclipse.org/artwork/● https://www.jetbrains.com/img/logos/logo_intellij_idea.gif● https://play.google.com/store/apps/details?id=com.aide.ui● https://developer.android.com/sdk/index.html● https://developer.android.com/reference/packages.html● https://developer.android.com/guide/topics/ui/layout/linear.html● http://curiousexpeditions.org/?p=78● http://actionbarsherlock.com● https://code.google.com/p/roboguice● http://marie-schweiz.de