Android workshop

732 views

Published on

Android development workshop held as part of Java class on Faculty of Electrical Engineering and Computing, University of Zagreb, Croatia.

22.06.2012. Zagreb

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
732
On SlideShare
0
From Embeds
0
Number of Embeds
36
Actions
Shares
0
Downloads
16
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • - neke stvari se mogu emulirati no ne sve\n- recimo emuliranje kamere, telefonskih poziva i slicno radi\n- ne moze se emulirati sensore, slobodno pokusajte tresti laptop, ali ne moj!\n- network bandwidth se moze mijenjati\n
  • \n
  • pokazati ini file\ngdje se nalazi SD kartica i slicno\nmksdcard za napraviti karticu rucno\nprilikom stvaranja AVD-a mozemo izabrati ili velicinu ili datoteku\n
  • \n
  • \n
  • \n
  • \n
  • radi deployment na emulator ili na uredjan no brine se za transfer i instalaciju na ciljanom uredaju\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Android workshop

    1. 1. Android predavanjeNikola Kapraljević, InfinumJava tečaj 22.06.2012, FER
    2. 2. Nikola Kapraljevićtwitter@nixanikola@infinum.hrAndroidRuby on RailsiPhone
    3. 3. Android OS
    4. 4. Android OSkoristi se za tablet i smartphone uređajetrenutno postoji preko 300 različitih telefona900 000 novih uređaja se aktivira dnevno330 000 000 uređaja je trenutno aktivno
    5. 5. Samsung Galaxy SIII
    6. 6. Izgled sučelja
    7. 7. HTC Sense
    8. 8. Motorola MotoWiz
    9. 9. Samsung TouchWiz
    10. 10. Sony Ericsson UX
    11. 11. Honeycomb 3.xtablet računala
    12. 12. Android4.0
    13. 13. Open source...
    14. 14. Android Arhitecture
    15. 15. Android OSLinux based OSno NIJE Linuxnema glibcnema X11nema konfiguracijske datoteke koje očekujemonema ni sve alate koji dolaze s Linuxom
    16. 16. Application FrameworkActivity Manager Resource ManagerWindow Manager Location ManagerContent Providers Notification ManagerView SystemPackage ManagerTelephony Manager
    17. 17. Dalvik VMvirtual machine koji izvršava Dalvik byte-codeslično JVM, no nije JVMJava se kompajlira u .dex datotekesvaka aplikacija se izvršava u vlastitomsandboxu i na vlastitoj instanci VM-aJava SE 5
    18. 18. Applicationsuz OS dolazi i određeni set aplikacija SMS Calendar Browser (Webkit) Contacts ....
    19. 19. Raspodjela Androidhttp://developer.android.com/resources/dashboard/platform-versions.html
    20. 20. Različite rezolucije/orijentacijeres/layout/main_activity.xml # For handsetsres/layout-land/main_activity.xml # For landscape handsetsres/layout-sw600dp/main_activity.xml # For tablets
    21. 21. Dashboardmost of the apps
    22. 22. Sidenavigation
    23. 23. Android Development
    24. 24. UI
    25. 25. layout.xmldefiniranje sučelja koristeći XMLandroid:id="@+id/my_button”moguće učitavanje on runtime pomocuLayoutInflater servicea super.onCreate(savedInstanceState); setContentView(R.layout.main_layout);
    26. 26. Button<Button android:id="@+id/my_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/my_button_text"/>
    27. 27. View system
    28. 28. Android LayoutsFrameLayoutLinearLayoutRelativeLayoutTableLayoutGallery
    29. 29. Android Widget ToolboxTextView RadioButtonEditText http:// developer.android.coListView m/guide/tutorials/Spinner views/index.htmlButtonCheckBox
    30. 30. http://developer.android.com/design/index.html
    31. 31. Actionbar Sherlockhttp://actionbarsherlock.com/
    32. 32. Custom ComponentsExtend an existing View class or subclass with your own class.Override some of the methods from the superclass. The superclassmethods to override start with on, for example, onDraw(),onMeasure(), and onKeyDown(). This is similar to the on... events inActivity or ListActivity that you override for lifecycle and otherfunctionality hooks.Use your new extension class. Once completed, your new extensionclass can be used in place of the view upon which it was based.example: extend ImageView and add some rounded borderhttp://developer.android.com/guide/topics/ui/custom-components.html
    33. 33. New project example
    34. 34. Projectsrc/assets/res/AndroidManifest.xml
    35. 35. AndroidManifest.xmlpermissions, activity, name, icon
    36. 36. strings.xml
    37. 37. Overriding resourcesres/values-en/strings.xmlres/layout-land/main.xmlres/drawable-ldpi/slika.pngres/drawable-hdpi/slika.pnghttp://developer.android.com/guide/topics/resources/providing-resources.html
    38. 38. R.javapointers from java to resources
    39. 39. R.javaR.layoutR.stringR.drawableR.animR.color
    40. 40. HomeActivity.java
    41. 41. Android Emulatornapraviti ćemo novi AVD, koristite x86 akomozete
    42. 42. telnet localhost port
    43. 43. ~/.android/avd
    44. 44. DDMS perspectivepozivi, sms, network speed
    45. 45. Pokretanje aplikacijecompiling, signing, deploying, running
    46. 46. ANTbuilding from command lineandroid update project -p .ant help :)
    47. 47. Android Debug BridgeSDK/tools/adb
    48. 48. Command line installadb install bin/Workshop.apkadb uninstall com.infinum.workshop
    49. 49. Application componentsActivitiesServicesContentProvidersBroadcast receivers
    50. 50. Activity lifecyclehttp://developer.android.com/reference/android/app/Activity.html
    51. 51. Android IntentsIntents are used as a message-passingmechanism that works both within yourapplication, and between applications. Declare your intention that an Activity or Service be started to perform an action, usually with (or on) a particular piece of data Broadcast that an event (or action) has occurred
    52. 52. Explicit intentsstartActivity Intent intent = new Intent(this, MyActivity.class); startActivity(intent);startActivityForResults Intent intent = new Intent(this, MyActivity.class); startActivity(intent);
    53. 53. Implicit intentstrazimo od OS-a da izabere pomocu cega ceizvrsiti Intent Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(‘tel: 0959115614’); startActivity(intent);
    54. 54. DetailsActivity exampleprenosenje i vracanje parametara sactivitya na activity
    55. 55. BroadcastsBroadcasting intents napravite intent i pozoveze nad njim sendBroadcast(intent);Receiving intents extend BroadcastReceiver register in android manifest <receiver android:name=".MyBroadcastReciver"> <intent-filter> <action android:name="hr.infinum.fer.LECTURE_DONE"/> </intent-filter> </receiver>
    56. 56. Phone callexample
    57. 57. String url = "tel:0959115614";Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse(url));
    58. 58. Permissions<uses-permissionandroid:name="android.permission.CALL_PHONE"></uses-permission>
    59. 59. Možemo li znati kad jepoziv gotov?
    60. 60. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button btnCall = (Button) findViewById(R.id.btnCall); btnCall.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:0917700")); startActivity(intent); } }); TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); tm.listen(new EndCallListener(), PhoneStateListener.LISTEN_CALL_STATE); } private class EndCallListener extends PhoneStateListener { @Override public void onCallStateChanged(int state, String incomingNumber) { Log.d("NIXA", "Phone state is " + state + " " + incomingNumber); } }
    61. 61. Permissions<uses-permissionandroid:name="android.permission.READ_PHONE_STATE"></uses-permission>
    62. 62. ListView
    63. 63. List adaptersArrayAdapterCursorAdapterSimpleCursorAdapter
    64. 64. ListView example
    65. 65. StorageShared PreferencesInternal StorageExternal StorageSQLite DatabasesNetwork Connection
    66. 66. Media and Cameratake photorecord videopick photo/video from galleryMediaStore.ACTION_IMAGE_CAPTUREMediaStore.ACTION_VIDEO_CAPTURE
    67. 67. Camera example
    68. 68. Paziti naLow processing powerLimited RAMLimited permanent storage capacitySmall screens with low resolutionHigh costs associated with data transferSlow data transfer rates with high latencyUnreliable data connectionsLimited battery life
    69. 69. ANRapplication notrespondingservices 10sactivities 5s
    70. 70. Support LibraryFragmentFragmentManagerFragmentTransactionListFragmentDialogFragmentLoaderManagerLoaderAsyncTaskLoaderCursorLoader
    71. 71. coloredlogcathttps://bitbucket.org/GBouerat/colored-logcat-pid
    72. 72. Flurryako vas zanima tko i kako koristi aplikaciju
    73. 73. AdMobako hocete nesto zaraditi, ali vjerovatnonecete
    74. 74. Android Market
    75. 75. Android MarketDeveloper Consolepratite komentareexceptioniActive Install Rate
    76. 76. Android Market25$ accountkad krenete razvijati applikaciju nije lošeuploadat ju odmah na početku developmentakako bi si rezervirali namespace(hr.infinum.nixa...)“od sljedećeg tjedna izgleda da ćemo moćikupovati/prodavati aplikacije i iz Hrvatske”DORS/CLUC 2011 - ovo jos uvijek ne radi :-)
    77. 77. Lamborgini Aventador700hp V12, 2.9s do 100km/h
    78. 78. Pitanja ...
    79. 79. Hvala!twitter@nixaskype@nkapraljnikola.kapraljevic@gmail.com

    ×