Advertisement
Advertisement

More Related Content

Advertisement
Advertisement

Android L01 - Warm Up

  1. Cloud InteractionDesign Android
  2. READ
  3. It’s no longer about Building
  4. Learn and Measure Don’t just Build
  5. Why do you want this?
  6. IMPACT.
  7. Web apps vs. Native apps
  8. iOS vs. Android
  9. Objective-C/ Swift vs. Java
  10. HTML5 and JavaScript <!DOCTYPE   html> <html>   <head>   <link rel="stylesheet"   href="styles.css"> <meta  charset="utf-­‐-­‐8"> <script src="scripts.js"></script> <title>hello,   world</title> </head> <body> hello, world   </body> </html>
  11. JavaScript <script  type="text/JavaScript">   function  loadFile(url) { var script   = document.createElement('SCRIPT'); script.src =   url;   document.getElementsByTagName('HEAD')[0].appendChild(script); } </script>
  12. XML Simple Email <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body> Don't  forget  me  this  weekend! </body> </note>
  13. Ajax and XMLHttpRequest
  14. jQuery http://jquery.com/
  15. Frameworks • jQuery Mobile • PhoneGap • Sencha Touch • Xamarin • AngularJS + iconic • … etc
  16. Gaming
  17. Games (OpenGL, Metal and the rest)
  18. How we are gonna do it.
  19. Googling StackOVerFlow
  20. Android
  21. Cloud
  22. User Experience Interaction Design
  23. User Experience
  24. User Experience
  25. JavaPrimer
  26. Install JRE, JDK
  27. Java JVM – Java Virtual Machine
  28. API http://java.sun.com/javase/6/docs/api/ Tutorial http://java.sun.com/docs/books/tutorial/java/TOC.html
  29. Java Write once, run anywhere
  30. Java Write once, run anywhere
  31. Reserved Words abstract continue for new switch assert*** default goto* package synchronized boolean do if private this break double implements protected throw byte else import public throws case enum**** instanceof return transient catch extends int short try char final interface static void class finally long strictfp** volatile const* float native super while http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
  32. Primitive Types byte short int long float double boolean char
  33. Variables Naming • Subsequent characters also can be numbers • Case sensitive • No spaces • Examples: name firstName phoneNumber
  34. Arrays int[]  grades; grades  =  new  int[15]; Control flow if  (boolean)  { //  perform  this  code }  else  { //  otherwise,  run  this }
  35. Referencing int hoursePower =  100; Car  myCar =  new  Car(hoursePower ); Car  yourCar =  new  Car(hoursePower +  50); myCar =  yourCar; Print(myCar.HorsePower);
  36. Packages vs Namespaces
  37. void  main(string[]  args)
  38. Instance vs Class methods void  shootBall(Point  point) static  void  main(string[]  args)
  39. Inheritance and Polymorphism extends,  super,  @Override
  40. Some diff. protected in a form of package scope not class scope
  41. Some diff. final  vs const vs readonly
  42. interfaces
  43. Collections
  44. Example ArrayList<String>   arrList =  new  ArrayList<String>(); arrList.add(“A”); arrList.add(“AB”); arrList.add(“ABC”); arrList.add(“ABCD”); //  using  indices arrList.set(0,   arrList.get(1)); arrList.set(1,   “foo”);
  45. Example • What does the following mean? ArrayList<String>   A1; //  bla bla List<String>   list  =  new  ArrayList<String>(A1);
  46. for-each • Looping by indices • for-each, parallel execution for  (Object  o  :  collection)   System.out.println(o);
  47. Collection Operations List<Type>   list1  =  new  ArrayList<Type>(); //  … List<Type>   list2  =  new  ArrayList<Type>(); //  … List<Type>   list3  =  new  ArrayList<Type>(list1);   list3.addAll(list2);
  48. List Algorithms • sort — sorts a List using a merge sort algorithm, which provides a fast, stable sort. (A stable sort is one that does not reorder equal elements.) • shuffle — randomly permutes the elements in a List. • reverse — reverses the order of the elements in a List. • rotate — rotates all the elements in a List by a specified distance. • swap — swaps the elements at specified positions in a List. • replaceAll — replaces all occurrences of one specified value with another. • fill — overwrites every element in a List with the specified value. • copy — copies the source List into the destination List. • binarySearch — searches for an element in an ordered List using the binary search algorithm. • indexOfSubList — returns the index of the first sublist of one List that is equal to another. • lastIndexOfSubList — returns the index of the last sublist of one List that is equal to another. See more @ http://docs.oracle.com/javase/tutorial/collections/interfaces/list.html
  49. Iterators
  50. Lambdaj lambda expression
  51. Lambdaj LINQ-like
  52. Lambdaj https://github.com/ooxi/lambdaj
  53. Multithreading synchronized,  wait,   notify,  notifyall
  54. Into Android!
  55. IDEs Eclipse, Android Studio
  56. Android versions and versions and versions
  57. Android Developer http://developer.android.com
  58. Tools • android - Android SDK manager. Create/delete/view Android Virtual Devices and update the SDK with new platforms/add- ons. • ddms - Dalvik Debug Monitor Server. Screen caps, thread/heap info, process/state info, .. • emulator - The application responsible for opening AVDs instances. • sqlite3 - manage SQLite databases.
  59. SDK – Cont. • # adb - Android Debug Bridge. A client/server program that manages the state of an emulated device. • # aapt - Android Asset Packaging Tool. • # dx - The converter; converts .class files to Android bytecode.
  60. Creating Your First Android App
  61. Create Project with Android Studio • Build SDK is the platform version against which you will compile your app. By default, this is set to the latest version of Android available in your SDK. • Minimum Required SDK is the lowest version of Android that your app supports
  62. Hello World
  63. Hello World
  64. Activity Life Cycle http://developer.android.com/reference/android/app/Activity.html
  65. File System
  66. File System
  67. Conventions
  68. USB Debugging
  69. Try it. Just run it.
  70. activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"  > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="@string/hello_world" tools:context=".MainActivity"  /> </RelativeLayout>
  71. Adding your first button • res > values > strings • Add toggle_message to strings file. • And in the activity_main.xml file <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textView1" android:layout_centerHorizontal="true" android:layout_marginBottom="18dp" android:text="@string/toggle_message"   />
  72. Adding your first button • res > values > strings • Add toggle_message to strings file. • And in the activity_main.xml file <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textView1" android:layout_centerHorizontal="true" android:layout_marginBottom="18dp" android:text="@string/toggle_message"   />
  73. Adding your first button • res > values > strings • Add toggle_message to strings file. • And in the activity_main.xml file <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textView1" android:layout_centerHorizontal="true" android:layout_marginBottom="18dp" android:text="@string/toggle_message"   />
  74. Adding a Click Event • MainActivity.java public  void  toggleMessageOnClick(View  view)  { TextView textView =  (TextView)findViewById(R.id.textView1); textView.setText("Bonjour  Monde!"); } • activity_main.xml <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textView1" android:layout_centerHorizontal="true" android:layout_marginBottom="18dp" android:text="@string/toggle_message“ android:onClick="toggleMessageOnClick"  />
  75. [OR] Adding a Click Event • MainActivity.java @Override         protected  void  onCreate(Bundle  savedInstanceState)  {                             super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);                 Button  btn =  (Button)findViewById(R.id.button1); btn.setOnClickListener(new  onClickListener()  {                     @Override                         public  void  onClick(View  arg0){                                 TextView textView =  (TextView)findViewById(R.id.textView1);                   textView.setText("Bonjour  Monde!");                         }                 }); } • activity_main.xml <Button .. android:onClick="toggleMessageOnClick"  />
  76. [OR] Adding a Click Event
  77. Run and see!
  78. Debug
  79. Debug Logging Log.d(“MY_TAG",  ”Any  message  here.");
  80. UI Elements
  81. What do you think is better/faster?
  82. What do you think is better/faster? faster slower
  83. Menus http://developer.android.com/guide/topics/ui/menus.html
  84. Menus Options Menu Context menu Popup Menu
  85. References
  86. READ
  87. Always! http://developer.android.com/
  88. Attend Harvard’s OpenCourseWare 201[2]! Building Mobile Applications, http://cs76.tv/2012/spring/ Mobile Software Engineering, http://cs164.tv/2012/spring/ Or Lynda, Udacity, Coursera
  89. Design Patterns, Gang of four
Advertisement