Marakana android-java developers


Published on

Published in: Technology, News & Politics
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Marakana android-java developers

  1. 1. Android  For  Java   Developers   Marko  Gargenta   Marakana  
  2. 2. Agenda   •  Android  History   •  Android  and  Java   •  Android  SDK   •  Hello  World!   •  Main  Building  Blocks   •  Debugging   •  Summary  
  3. 3. History   2005   Google  buys  Android,  Inc.   Work  on  Dalvik  starts   2007   OHA  Announced   Early  SDK   2008   G1  Announced   SDK  1.0  Released   2009   G2  Released   Cupcake,  Donut,  Eclair  
  4. 4. Android  and  Java   Android Java = Java SE – AWT/Swing + Android API
  5. 5. Android  SDK  -­‐  What’s  in  the  box   SDK Tools Docs Platforms Data Skins Images Samples Add-ons Google Maps
  6. 6. The  Tools   Tools are important part of the SDK. They are available via Eclipse plugin as well as command line shell.
  7. 7. HELLO  WORLD!  
  8. 8. Create  New  Project   Use the Eclipse tool to create a new Android project. Here are some key constructs: Project   Eclipse  construct   Target   minimum  to  run   App  name   whatever   Package   Java  package   AcXvity   Java  class  
  9. 9. The  Manifest  File   <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="" package="com.marakana" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".HelloAndroid" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="5" /> </manifest>
  10. 10. The  Layout  Resource   <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout>
  11. 11. The  Java  File   package com.marakana; import; import android.os.Bundle; public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }
  12. 12. Running  on  Emulator  
  14. 14. AcXviXes   Activity is to an Android Application application what a Main Activity Another Another Activity Activity web page is to a website. Sort of.
  15. 15. AcXvity  Lifecycle   Starting Activities have a well- (1) onCreate() (2) onStart() (3) onRestoreInstanceState() defined lifecycle. The (4) onResume() Android OS manages your activity by Running changing its state. (3) onResume() (2) onStart() (1) onSaveInstanceState() (2) onPause() You fill in the blanks. (1) onRestart() onResume() (1) onSaveInstanceState() Stopped (2) onStop() Paused onDestroy() or <process killed> <process killed> Destroyed
  16. 16. Intents   Intents are to Android Application Android apps Another Main Activity Intent what hyperlinks Activity are to websites. They can be Intent implicit and Android Application explicit. Sort of like absolute and Main Activity Intent Another Activity relative links.
  17. 17. Services   A service is something that can be started and stopped. It doesn’t have UI. It is typically managed by an activity. Music player, for example
  18. 18. Service  Lifecycle   Service also has a Starting lifecycle, but it’s (1) onCreate() much simpler than (2) onStart() activity’s. An activity onStart() typically starts and stops a service to do Stopped Running some work for it in the background. onStop() Such as play music, check for new onDestroy() or tweets, etc. <process killed> Destroyed
  19. 19. Content  Providers   Content Providers share Content content with applications Provider across application Content URI boundaries. insert() Examples of built-in update() Content Providers are: delete() Contacts, MediaStore, query() Settings and more.
  20. 20. Broadcast  Receivers   An Intent-based publish-subscribe mechanism. Great for listening system events such as SMS messages.
  22. 22. LogCat   The universal, most versatile way to track what is going on in your app. Can be viewed via command line or Eclipse. Logs can be generated both from SDK Java code, or low-level C code via Bionic libc extension.
  23. 23. Debugger   Your standard debugger is included in SDK, with all the usual bells & whistles.
  24. 24. TraceView   TraceView helps you profile you application and find bottlenecks. It shows execution of various calls through the entire stack. You can zoom into specific calls.
  25. 25. Hierarchy  Viewer   Hierarchy Viewer helps you analyze your User Interface. Base UI tends to be the most “expensive” part of your application, this tool is very useful.
  26. 26. Summary   Android is based on Java. You write Java code, but technically don’t run it. Java is augmented with XML, mostly for UI purposes. Android Java is mostly based on Java SE with replacement UI libraries. Marko Gargenta, +1-415-647-7000 Licensed under Creative Commons License (cc-by-nc-nd). Please Share!