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.
2. 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.
3. About Me
Name: Justin Grammens
Owner Localtone Interactive - http://www.localtone.com
Focus 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 years
Enjoy working in new technologies
VoIP
Asterisk
Adhearsion
Mobile
Android
iPhone
Looking to start a mobile developers monthly meetings
4. Summary
Meet our friend quot;ANDYquot;
History
Anatomy of quot;ANDYquot;
Setting up the environment
Sample Applications
Android Market
Discuss
6. 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
7. What Android Is
Built on the Linux kernel
Uses the Dalvik virtual machine
Register Based VM written by Dan Bornstein
Very low memory footprint
Core and 3rd party applications have equal access
Multiple applications able to run at the same time
Copy and Paste functionality
Background services
Able to embed HTML, Javascript and stylesheets
100% fully customizable
Handles native and streaming playback of mutimedia
Currently supports developing apps in Java
8. What's the big deal?
Truly open and FREE development platform.
No quot;pay to playquot; developer agreement
Freely available tools (Eclipse) and no restrictions on OS
you need to be on to develop.
Component based architecture that can be extended
Built in services out of the box.
Location based
Multimedia - 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
9. How was quot;ANDYquot; 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.
11. Anatomy of quot;ANDYquot;
Basic foundation of an Android application
Activity
Intent
Service
Content Provider
Your applications will not use all of these, but
they will use atleast one.
12. Anatomy of quot;ANDYquot;
Activity
Describes a single screen of the application
Implemented as a class that extends Activity
Activities are pushed on the history stack using an
Intent
Uses callbacks to trigger events during state changes.
public class LocaltoneAndroid extends ListActivity {
@Override
public void onCreate(Bundle init) {
}
}
14. Anatomy of quot;ANDYquot;
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(quot;http://localtone.comquot;));
15. Anatomy of quot;ANDYquot;
Service
Code that is long running
Runs without a UI
Media Player is an good example
Activity used to choose song
Playback handled in a service
public class MyService extends Service {
public void onCreate() {
}
}
16. Anatomy of quot;ANDYquot;
Content Provider
Set of data wrapped in a custom API
Allow sharing of data between applications
Processes 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
17. Face of quot;ANDYquot;
Various types of Layouts - Similar to Swing
Linear Layout
Arranges children in a single row/column. The most
common type of layout you'll use.
FrameLayout
Arranges children so they start at the top left. Used
mainly for tabbed views.
Relative Layout
Arranged in relation to eachother ( element X is
above/below element Y for example ).
TableLayout
Arranged in a cells, like HTML table.
18. XML File Layout Example
About.xml
<LinearLayout xmlns:android=quot;http://schemas.android.
com/apk/res/androidquot;
android:orientation=quot;verticalquot;
android:layout_width=quot;fill_parentquot;
android:layout_height=quot;fill_parentquot;>
<TextView android:id=quot;@android:id/helloquot;
android:layout_width=quot;wrap_contentquot;
android:layout_height=quot;wrap_contentquot;
android:text=quot;@string/helloquot; />
</LinearLayout>
19. Face of quot;ANDYquot;
Declarative - In XML
Task: Define text in an quot;Aboutquot; screen
File: res/layout/about.xml
<TextView android:id=quot;@+id/about_contentquot;
android:layout_width=quot;wrap_contentquot;
android:layout_height=quot;wrap_contentquot;
android:text=quot;@string/about_textquot; />
File: About.java
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.about);
}
20. Face of quot;ANDYquot;
Procedural - In Code
Create a TextView object, set the text and behavior
TextView pressMe = new TextView(context);
pressMe.setText(quot;Press Mequot;);
addView(mDialogue, new LinearLayout.LayoutParams(
FILL_PARENT, WRAP_CONTENT));
21. Face of quot;ANDYquot;
Android Manifest.xml
What is any good Java program with a manifest file? =)
Defines the version and package information
Defines the permissions required by the application
<uses-permission android:name=quot;android.
permission.INTERNETquot; />
Class name
<activity android:name=quot;.Resultquot;
of the Activity
android:label=quot;@string/resultquot;
android:layout_width=quot;fill_parentquot;>
</activity>
22. Developing Apps for quot;ANDYquot;
Develop using Windows, Linux or Mac
Free to develop and deploy to your device
Recommend using to Eclipse IDE and Android Plugin
Download IDE and from
IDE - http://eclipse.org
Install Android plugin through the Eclipse Plug-in
Manager
SDK
http://code.google.com/android/intro/installing.html
Demo of IDE and Basic Apps
Localtone Radio
PandaRiffic
23. Pimping quot;ANDYquot; for Profit
Listing apps in the Android Market
Must be digitally signed
Just opened up paid applications last week
Your Manifext.xml tells the story:
<manifest xmlns:android=quot;http://schemas.android.
com/apk/res/androidquot;
package=quot;com.example.package.namequot;
android:versionCode=quot;2quot;
android:versionName=quot;1.1quot;
android:minSdkVersion = 1.0>
Version code - The version relative to other versions
Version name - The version that people will see
24. Distribution of Apps
Download 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
25. Pimping quot;ANDYquot; For Profit
Steps to sign and publish your application
1. Compile the application in release mode
1. Export from Eclipse as an APK file
2. Android Tools -> Export Unsigned Application
Package
2. Obtain or create a suitable private key (you can not
use the debug key that comes with the SDK)
1. Use keytool
2. keytool -genkey -v -keystore my-release-key.
keystore -alias alias_name -keyalg RSA -validity
10000
26. Pimping quot;ANDYquot; for Profit
Continued steps to sign and publish your application
1. Sign the application with your private key
1. Use jarsigner tool
2. jarsigner -verbose -keystore my-release-key.keystore
my_application.apk alias_name
3. jarsigner -verify my_signed.apk
2. Secure your private key
1. Select strong passwords for your keystore
2. Do not specify password on the command line as they
will be available in your shell history
Instructions and best practices
http://code.google.com/android/devel/sign-publish.html
27. Pimping quot;ANDYquot; For Profit
NOTE: You can distribute your .apk file and charge any
way you wish!
However, if you wish to use the Market
URL: http://www.android.com/market
1. Signup on the market
1. http://market.android.com/publish/signup
2. Pay $25 registration fee.
2. Uses Google Checkout for payment processing
3. 70% for you, 30% for the carrier (T-Mobile)
4. Google offers an unlocked G1 for $399
5. No other major restrictions that I know of
28. Pimping quot;ANDYquot; for Profit
Updates
1. The Market does not yet support user notification
of updates to your application
2. Suggestions on how to overcome this in your
application
1. 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.
31. Final Thoughts
iPhone's game changing success
Central distribution through iTunes.
Sexy design.
quot;Openquot; (as they call it) Developer platform.
Own the software AND the hardware.
Android
Open Source and freely available
Hardware independent. Phones set to be released in 2009
year from Motorola, Samsung, Ericsson, Huawei, Lenovo
Develop applications anywhere Java can run.
Distribute applications for free. $25 if you choose to use
Android Market.
32. Final Thoughts
It's not just mobile devices!
Recent Headlines:
Asustek to Make Google Android Netbook, Says Report -PC
World
Android wants to be on any device, not just your phone -
VentureBeat
Android Beyond the Phone - moto.com (referring to Android
running eInk devices)
Skins - Shows different devices
http://teavuihuang.com/android/
Wish Google would promote job postings like 37 Signals
33. 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 G2
Official MS Exchange support?
ASUS Netbooks
Android is Linux's second chance
34. Resources
Books
Hello, Android by Pragmatic Programmers
Free PDF by AndDev.org - http://href.to/AB1
Sites
AndDev.org - Good online forum
Google Samples - http://is.gd/knVZ
IRC
#Android
Google Groups
Android Developers
http://is.gd/knWK
Android Dev MN
http://is.gd/knVO
Performance/Developer Tips - http://is.gd/g5re