1 / 9

Plan for today

Explore the Android.util.Log class and understand its usage for debugging. Learn about the MVC (Model View Controller) design pattern and its implementation in an Android project. Review Java language concepts and explore the power of Android Studio for developing robust and debuggable applications.

lulaa
Download Presentation

Plan for today

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Plan for today • Toward debugging and understanding • Today: android.util.Log • Next week: debugger • Reviewing the onCreate, onStart, onX methods of an Android Activity • What happens when you rotate your phone? • MVC: Model View Controller: project • Reviewing Java concepts

  2. android.util.Log • https://developer.android.com/reference/android/util/Log.html • Why is this android.util and not java.util? • Path and package name • Where does Log write data? Why would you use Log rather than System.out? • What about what's on your phone? • Can your App "phone home" with log info?

  3. Review log changes protected void onStart() { super.onStart(); Log.d(DTAG,"onStart " + getIDs());} private String getIDs(){ return String.format("myId = %d, instance = %d", myInstanceID,ourInstances);} private int myInstanceID;private static int ourInstances;private static String DTAG = "MainActivityDebug";

  4. Java Language Concepts • Static variables are per class, not per object • If you create 100 Pixel objects, each has it's own r,g,b values, e.g., in myRed, myGreen, myBlue • Total number of pixels ever created would be a static variable, not an instance variable! • Use formatted strings, e.g., String.format rather than concatenating strings • Android is smart about String + v. StringBuilder

  5. Concepts for next project • Review Activity, Layout, Resources • Model examples we've done, use Android Developer documentation, read and read and read • You'll create a "quiz". Could be anything, Buzzfeed, Duolingo TinyCards, something simple • Source of quiz • UI of taking quiz • Persistence of quiz

  6. Model View Controller • (aka MVC) This object-oriented design pattern is ubiquitous • Main idea is that controller mediates between model and view, M and V loosely coupled • http://stackoverflow.com/questions/29594105/mvc-is-it-model-to-view-or-controller-to-view

  7. Activity, Views, MVC and Project • Where are Views created, how are they accessed? • Activity accesses widgets via findViewById, use the power of Android Studio to help • Instance variables access state across methods, e.g., myLeftButton • What should the source of questions be? • Not in Activity, why not? • Not in XML file, why not? • Loose coupling, High cohesion

  8. Android Concepts • https://gitlab.oit.duke.edu/ola/quizmaster • How do you make a custom/app icon? • Where do you store images? • Why are there so many version of images? • What is a toast? Toast.makeText( MainActivity.this, "left click, total = "+ourButtonCount, Toast.LENGTH_SHORT).show();

  9. Java Concepts • What is a constructor? What is a method? What is an instance variable? • What do access modifiers mean: public, private, protected? • Java vs. what we're doing wrt protected • Inner classes and how they work, toward creating an Interface

More Related