Android: Looking beyond the obvious

  • Published on

  • View

  • Download

Embed Size (px)


<ul><li> 1. AndroidLooking beyond the obvious10/20/11Cocoaheads Siegen Dipl. Inform. Simon Meurer</li></ul> <p> 2. Agenda General Android Desktop Developers View Publishing10/20/11 2 3. What is Android? OS and Software-platform for different Mobile Devices Developed by Open Handset Alliance Based on Linux-Kernel 2.6 Biggest rival of iOS on Smartphone OS-Market10/20/11 3 4. Market share504543,44035302522,120 18,21511,710 5 1,9 1,6 1 0 Android Symbian iOSRIM Bada Microsoft Others 2nd quartal 2011 Market share (%) - source: Gartner10/20/114 5. Sample Devices10/20/115 6. Android Versions 2.x for mobile phones (act. 2.3.6) 3.x for tablets (act. 3.2) 4.x gets 2.x and 3.x together10/20/116 7. Android Desktop Apps in MenuCan be moved to Desktop Themes and Live-Background Shortcuts No. of Desktops set by Theme10/20/11 7 8. Widgets10/20/11 8 9. Notifications and Preferences10/20/11 9 10. Developers View Architecture Language Key Concepts Menues Environment10/20/11 10 11. Architecture10/20/1111 12. Language Android is Java, right? Yes, but:No Constructors (for GUI-Classes)No Swing or SWTNo System.out.println(...)Limited memory...10/20/11 12 13. Key Concepts Activities Layouting with XML Intents Services Content Providers Resources10/20/11 13 14. Activities UI-Screen (better: logic) An app has usually more than one Activity StackNew Activities pushed on stackBack pops them of10/20/1114 15. Example ( com.test.helloworld;import;import android.os.Bundle;public class HelloWorldActivity extends Activity {/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);}}10/20/1115 16. Layouting with XML GUI is build in XML Tags = Elements, Attributes = Properties Different Resolutions possible No Absolute Layout, instead:LinearLayout, RelativeLayout, TableLayout, Place in XML = Place in Layout10/20/1116 17. Example (main.xml)10/20/1117 18. HelloWorld10/20/1118 19. Clicking the buttonpublic class HelloWorldActivity extends Activity {public void onCreate(Bundle savedInstanceState) {...Button b = (Button) findViewById(;b.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View arg0) {Toast.makeText(HelloWorldActivity.this, "Hello World!",Toast.LENGTH_SHORT).show();Log.v("HelloWorldActivity", "Hello clicked");}});}}10/20/11 19 20. Toasting and Logging Toastdisplaying short Text for a short while NOT for debugging Logis for logging on consoleDifferent levels: d, e, i, v, w10/20/11 20 21. So, what about other Activities? Problem: No Constructors for GUI-Classes Intent:Describes a spec. Actione.g. pick a photo, take a picture, create personStandards: send an email, Can be registered as standardIntents extras = Values of Constructors10/20/1121 22. Example (Intents)onClick of Hello-Button:Intent i = new Intent(HelloWorldActivity.this, HelloWorldActivity2.class);i.putExtra("Hello", "World");startActivity(i);HelloWorldActivity2:public class HelloWorldActivity2 extends Activity{protected void onCreate(Bundle savedInstanceState) {...TextView t = (TextView) findViewById(;t.setText(getIntent().getStringExtra("Hello"));}}10/20/11 22 23. How do I get results? 1.startActivityForResult(Intent, requestCode) 2.Generate result and put it in the intent 3.set resultCode and finish() the activity onActivityResult(requestCode, resultCode, Intent data) is your result10/20/1123 24. Services Task that runs in background e.g. Music Player Can be started by Activity1 Changed by Activity2 e.g. Activity2 says stop or nextTrack Live Wallpaper10/20/11 24 25. Resources Manage data with xml Resource-Class is generated automaticallyholds ids for the elements Contains:Layouts, Strings, Images, Values, Menus, Settings10/20/1125 26. Menu, Contextmenu and Search10/20/11 26 27. Development environment Recommended: Eclipse Fully integrated:GUI-BuilderXML-HelperConsoleDebugging-Tools10/20/11 27 28. GUI-Builder10/20/11 28 29. XML-Helper10/20/1129 30. Console and Debugging-Tools10/20/11 30 31. Where do I publish my App? Android Market:510,000 Apps in Sept. 2011 uses Google Checkout for billing takes 30% of the app-price Until now:No controlles!10/20/1131 32. Publishing on Android MarketRequirements: Google Account register as developer on 25$ only Creditcards For charged apps:register at Google Checkout10/20/1132 33. Publishing on Android MarketRequirements for the App: App must be signedexpires after 22.10.2033 AndroidManifest.xml:android:versionCode and android:versionName must be definedandroid:Icon and android:label must be defined10/20/1133 34. Publishing without Android Market Complete free:Generate .apk Put .apk on your website .apk must be copied to device and installed (e.g. with APK-Manager) Problems:No (normal) User will do that!Billing, integration, updates10/20/11 34 35. Publishing without Android Market Alternative Markets:Amazon App Store (about 18,000 Apps) SlideME (about 10,000 Apps) AndAppStore (about 2,000 Apps) OnlyAndroid But:Google can delete your app at any time!Not so many customers10/20/11 35 36. Lessons learned Android is NOT Java XML-Layouting is not allways fun Complicated solutions for simple problems Intents are sometimes mysterious Looks half-baked sometimes Docu is not as good as iOS-Docu10/20/11 36 37. But... Costs:Development for free Publishing 25$ once Market share Mainly Java Freedom of choice ...10/20/1137</p>


View more >