android intro

35

Upload: justin-grammens

Post on 28-Jan-2015

112 views

Category:

Technology


1 download

DESCRIPTION

My presentation on Android to the Ruby Users of Minnesota group. Introduces the platform, demo applications I wrote and how to list your app in the Android market.

TRANSCRIPT

Page 1: Android Intro
Page 2: Android Intro

What is Android?Definition:

Android is a software platform and operating system for mobile devices, based on the Linux kernel, developed by Google and later the Open Handset Alliance.

Source: Wikipedia

Would argue that it's not just for mobile devices. Has the potential to be used in all sorts of other areas where memory, cpu and disk is limited.

Page 3: Android Intro

About MeName: Justin Grammens

Owner Localtone Interactive - http://www.localtone.comFocus on mobile, internet and voice applications Support and advocate for open formats (ogg, odf)

Background in Java Working in Ruby/Rails on/off for the past 2 yearsEnjoy working in new technologies

VoIPAsteriskAdhearsion

MobileAndroidiPhone

Looking to start a mobile developers monthly meetings

Page 4: Android Intro

SummaryMeet our friend "ANDY"HistoryAnatomy of "ANDY"Setting up the environmentSample ApplicationsAndroid MarketDiscuss

Page 5: Android Intro

!=

Android is NOT the G1!

ANDY

Page 6: Android Intro

What Android Is

A Project of the Open Handset Alliance (OHA) - More than 30 technology companies

Source: Presentation by Sean Sullivan - http://mobileportland.com/content/introduction-google-android

Page 7: Android Intro

What Android IsBuilt on the Linux kernelUses the Dalvik virtual machine

Register Based VM written by Dan BornsteinVery low memory footprint

Core and 3rd party applications have equal accessMultiple applications able to run at the same timeCopy and Paste functionalityBackground services Able to embed HTML, Javascript and stylesheets100% fully customizableHandles native and streaming playback of mutimedia Currently supports developing apps in Java

Page 8: Android Intro

What's the big deal?Truly open and FREE development platform.

No "pay to play" developer agreementFreely available tools (Eclipse) and no restrictions on OS you need to be on to develop.

Component based architecture that can be extendedBuilt in services out of the box.

Location basedMultimedia - supports OGG!SQLite Database

Automatic management of application lifecycle.Portability across current and future hardware.

Supports and plans for input from either trackball, keyboard or touch

Page 9: Android Intro

How was "ANDY" born?In July 2005 Google bought Android, Inc.December 2006, rumors surface that Google was developing a Google-branded handset November 2007, the Open Handset Alliance was unveiled with the goal of open standards for mobile devices.January - April 2008, Android Developer Challenge. Google offers 10 million dollars (50 teams winning $25,000 each). The second round 10 teams received $275,000 and 10 teams received $100,000 each.Since October 2008, Android source has been available as Open Source under the Apache license.Uses git. Details on source at: http://source.android.com October 22, 2008 the HTC Dream (T-Mobile G1) was launched as the first Android powered phone.

Page 10: Android Intro

DNA of "ANDY"

Page 11: Android Intro

Anatomy of "ANDY"

Basic foundation of an Android application

Activity IntentServiceContent Provider

Your applications will not use all of these, but they will use atleast one.

Page 12: Android Intro

Anatomy of "ANDY"Activity

Describes a single screen of the applicationImplemented as a class that extends ActivityActivities are pushed on the history stack using an IntentUses callbacks to trigger events during state changes.

public class LocaltoneAndroid extends ListActivity { @Override public void onCreate(Bundle init) { } }

Page 13: Android Intro

Activity Life Cycle

source: Hello, Android by Pragmatic Programmers

Page 14: Android Intro

Anatomy of "ANDY"

Intent An Intent describes what you would like to have done. Create new screen using activity and intents Intent i = new Intent(this, MyNewActivity.class); startActivity(i); or open a web page new Intent(android.content.Intent.VIEW_ACTION, ContentURI.create("http://localtone.com"));

Page 15: Android Intro

Anatomy of "ANDY"Service

Code that is long runningRuns without a UIMedia Player is an good example

Activity used to choose songPlayback handled in a service

public class MyService extends Service { public void onCreate() { } }

Page 16: Android Intro

Anatomy of "ANDY"Content Provider

Set of data wrapped in a custom APIAllow sharing of data between applicationsProcesses register themselves as a Content Provider. Anyone can share data. Google shares contacts, address, phone, etc. can be accessed by applications.

private String[] cols={android.provider.Contacts.PeopleColumns.NAME}; private Cursor cur = managedQuery(android.provider.Contacts.People.CONTENT_URI, cols, null, null);http://developer.android.com/reference/android/provider/package-summary.html

Page 17: Android Intro

Face of "ANDY"Various types of Layouts - Similar to Swing

Linear LayoutArranges children in a single row/column. The most common type of layout you'll use.

FrameLayoutArranges children so they start at the top left. Used mainly for tabbed views.

Relative LayoutArranged in relation to eachother ( element X is above/below element Y for example ).

TableLayoutArranged in a cells, like HTML table.

Page 18: Android Intro

XML File Layout ExampleAbout.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@android:id/hello" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello" /></LinearLayout>

Page 19: Android Intro

Face of "ANDY"Declarative - In XML Task: Define text in an "About" screenFile: res/layout/about.xml <TextView android:id="@+id/about_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/about_text" /> File: About.java protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.about); }

Page 20: Android Intro

Face of "ANDY"

Procedural - In Code

Create a TextView object, set the text and behavior

TextView pressMe = new TextView(context); pressMe.setText("Press Me"); addView(mDialogue, new LinearLayout.LayoutParams( FILL_PARENT, WRAP_CONTENT));

Page 21: Android Intro

Face of "ANDY"Android Manifest.xml

What is any good Java program with a manifest file? =) Defines the version and package informationDefines the permissions required by the application

<uses-permission android:name="android.permission.INTERNET" />

<activity android:name=".Result" android:label="@string/result" android:layout_width="fill_parent"> </activity>

Class name of the Activity

Page 22: Android Intro

Developing Apps for "ANDY"Develop using Windows, Linux or MacFree to develop and deploy to your device Recommend using to Eclipse IDE and Android PluginDownload IDE and from

IDE - http://eclipse.orgInstall Android plugin through the Eclipse Plug-in Manager

SDKhttp://code.google.com/android/intro/installing.html

Demo of IDE and Basic Apps

Localtone Radio PandaRiffic

Page 23: Android Intro

Pimping "ANDY" for ProfitListing apps in the Android Market

Must be digitally signedJust opened up paid applications last week

Your Manifext.xml tells the story:<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.package.name" android:versionCode="2" android:versionName="1.1" android:minSdkVersion = 1.0>

Version code - The version relative to other versionsVersion name - The version that people will see

Page 24: Android Intro

Distribution of AppsDownload applications as .apk file (Android PacKage)Can run inall .apk files on the device directly or even from the emulator using the command

./adb install FILENAME.apk

No restricition on distribution and free to charge whatever you wish.

Download right to the phone from the browser

Upload your application to your webserver.Set the content type to be application/android-package

Page 25: Android Intro

Pimping "ANDY" For ProfitSteps to sign and publish your application 1. Compile the application in release mode

1. Export from Eclipse as an APK file2. Android Tools -> Export Unsigned Application

Package2. Obtain or create a suitable private key (you can not

use the debug key that comes with the SDK)1. Use keytool2. keytool -genkey -v -keystore my-release-key.

keystore -alias alias_name -keyalg RSA -validity 10000

Page 26: Android Intro

Pimping "ANDY" for ProfitContinued steps to sign and publish your application 1. Sign the application with your private key

1. Use jarsigner tool2. jarsigner -verbose -keystore my-release-key.keystore

my_application.apk alias_name3. jarsigner -verify my_signed.apk

2. Secure your private key1. Select strong passwords for your keystore2. Do not specify password on the command line as they

will be available in your shell history Instructions and best practiceshttp://code.google.com/android/devel/sign-publish.html

Page 27: Android Intro

Pimping "ANDY" For ProfitNOTE: You can distribute your .apk file and charge any way you wish! However, if you wish to use the MarketURL: http://www.android.com/market 1. Signup on the market

1. http://market.android.com/publish/signup2. Pay $25 registration fee.

2. Uses Google Checkout for payment processing3. 70% for you, 30% for the carrier (T-Mobile)4. Google offers an unlocked G1 for $3995. No other major restrictions that I know of

Page 28: Android Intro

Pimping "ANDY" for ProfitUpdates1. The Market does not yet support user notification

of updates to your application2. Suggestions on how to overcome this in your

application1. Have your application check for updates.2. market://details?id=<MarketAppIdString>3. Easy to use Intents to fire up the market

application to download your update.3. I have been getting updates for a number of

applications I have downloaded.

Page 29: Android Intro

Pimping "ANDY" for Profit

Page 30: Android Intro

Pimping "ANDY" for Profit

Page 31: Android Intro

Final ThoughtsiPhone's game changing success

Central distribution through iTunes.Sexy design."Open" (as they call it) Developer platform.Own the software AND the hardware.

Android

Open Source and freely availableHardware independent. Phones set to be released in 2009 year from Motorola, Samsung, Ericsson, Huawei, LenovoDevelop applications anywhere Java can run.Distribute applications for free. $25 if you choose to use Android Market.

Page 32: Android Intro

Final ThoughtsIt's not just mobile devices!Recent Headlines:

Asustek to Make Google Android Netbook, Says Report -PC WorldAndroid wants to be on any device, not just your phone - VentureBeatAndroid Beyond the Phone - moto.com (referring to Android running eInk devices)

Skins - Shows different deviceshttp://teavuihuang.com/android/

Wish Google would promote job postings like 37 Signals

Page 33: Android Intro

ANDY's Future

More phones set to be released later this year.Operating System supports multi-touch. Will they offically support it?Virtual keyboard with G2Official MS Exchange support?ASUS NetbooksAndroid is Linux's second chance

Page 34: Android Intro

ResourcesBooks

Hello, Android by Pragmatic Programmers Free PDF by AndDev.org - http://href.to/AB1

Sites AndDev.org - Good online forumGoogle Samples - http://is.gd/knVZ

IRC#Android

Google GroupsAndroid Developers

http://is.gd/knWK Android Dev MN

http://is.gd/knVOPerformance/Developer Tips - http://is.gd/g5re

Page 35: Android Intro

Thank you

BYE