Android 101 workshop

Post on 12-May-2015

673 views 1 download

Tags:

description

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

Transcript of Android 101 workshop

Android 101 workshopGetting started with Android development

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

Agenda

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

The Setup

Platform of choice

LinuxMacWindowsAndroid

The Setup

Development Environment

http://eclipse.org

https://www.jetbrains.com/idea

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

The Setup

Android SDK

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

Hello Android

AndroidManifest.xml

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

manifest-intro.html

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>

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">

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 />

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 /> !

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>

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>

!

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.

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.

Intent

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>

Views

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

Views

User interaction

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

Libraries

Libraries

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

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

Questions

Get your keyboards clicking!

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

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