Theory of Computation: Lecture 30

Uploaded on

1) Another characterization of primitive recursive functions …

1) Another characterization of primitive recursive functions
2) Reduction of function arguments in primitive recursive functions
3) Construction of a computable functions that enumerates all unary primitive recursive functions
4) There exist computable functions that are not primitive recursive
5) Class home page is at

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Android Programming Lecture 01 Vladimir Kulyukin Department of Computer Science Utah State
  • 2. Outline ● Topics ● Learning Objectives ● Software Installation ● Documentation and Coding Resources ● Android OS ● Components of the Android Application ● XML
  • 3. Web Logistics ● The home page for this class is at ● Check the home page periodically and follow the links to read the syllabus, access slides, download code, download assignments, look up contact information, grading policies, watch screencasts,
  • 4.
  • 5. Android OS ● Background ● Software stack ● Activities vs. applications ● Activity life cycles ● Activity states ● Resources ● Android OS vs. iPhone
  • 6. User Interfaces ● Views ● Layouts ● Widgets ● UI XML
  • 7. Intents, Receivers, Adapters ● Explicit Intents ● Implicit Intents ● Event Broadcasting with Intents ● Event Reception with Broadcast Receivers ● Adapters and Data
  • 8. Files, Content Providers, Databases ● Saving and Loading Files ● SQLite Databases ● Access Exposure to Data Sources through Content Providers ● Content Provider Registration ● Native Content
  • 9. Location-Based Services ● What Are Location-Based Services? ● Configuring the Android Emulator for Location- Based Services ● Geocoding and Map-Based
  • 10. Multimedia ● Playing Audio and Video ● Recording Audio and Video ● Using the Camera to Take and Process
  • 11. Networking ● Internet Access ● HTML/XML Parsing ●
  • 12. Touchscreen ● Touch Event Capture ● Touch Screen Gesture
  • 13. Learning
  • 14. Learning Objectives ● Have an appreciation of the Android OS ● Know how to develop basic UIs ● Know how to broadcast and receive events ● Know how to manage data storage through files, databases, and content providers ● Know how to implement basic location-based services ● Know how to use audio and video
  • 15. Learning Objectives ● Know how to access the Internet ● Know how to process URL data encoded in HTML/XML ● Know how to capture touchscreen events and recognize touchscreen gestures ● Become exposed to Android online resources and
  • 16. Documentation and Coding
  • 17. Official Android Site
  • 18. Texts Rito Meier Professional Android 2 Application Development Wiley
  • 19. Texts Sayed Hashimi, Satya Komatineni, Dave MacLean Pro Android 2,
  • 20. Texts Mark Murphy Beginning Android 2,
  • 21. Pedagogical Principles ● I am your colleague, not a supervisor ● It is impossible to know everything about Android given the pace of change in mobile computing: do your own research and due diligence ● If you have a problem, google/bing/yahoo it: chances are someone else has had that problem or similar problem and posted a fix
  • 22. Software
  • 23. List of Software Tools ● OS: Windows (XP or later), Linux (Ubuntu 10.10), Mac OS (10.x or later) ● Java Development Kit (6 or later) ● Android SDK ● Eclipse IDE ● ADT Plugin for Eclipse
  • 24. Java JDK and JRE ● Java Development Kit (JDK) – Required to develop applications in Java – Contains a Java compiler, debugger, documentation tools, and other tools ● Java Runtime Environment (JRE) – Allows you to run a Java
  • 25. Android SDK● Tools that help you develop mobile applications on the Android platform – Android Development Tools (ADT) Plugin – Android Emulator ● Device-emulation tool that you can use to design, debug, and test your applications in an actual Android run-time environment without an actual phone – Android Virtual Devices (AVDs) ● Virtual device configurations that you create, to model device characteristics in the Android Emulator ● Each AVD functions as an independent device with its own storage for user data, SD card, and so
  • 26. Why Eclipse ● Integrated development environment (IDE) – Similar to Microsoft Visual Studio – Not required for Android development ● Alternatives include – Command-line based tools only – Other IDEs, e.g., NetBeans ● Google documentation refers to Eclipse
  • 27. Android
  • 28. Background History ● There exists a great variety of mobile operating systems: Symbian OS, MS Windows Mobile, Mobile Linux, iPhone OS, Moblin, etc ● Great market fragmentation ● So far no single OS has become the de facto standard (I personally doubt there will ever be one mobile OS; more likely two or three major mobile OSs and a few minor ones)
  • 29. Background History ● In 2005, Google acquires the startup company Android, Inc. ● In 2005, the work begins on the Dalvik VM and other components of the Android Platform ● In 2007, the Open Handset Alliance is formed by a group of companies (Sprint, Motorola, Samsung, Sony Ericsson, Google, Intel, Texas Instruments, etc)
  • 30. Background History ● The Open Handset Alliance releases a lot of IP through the Apache License, Version 2.0 ● In Nov. 2007, the first version of the Android SDK is released ● In Sept. 2008, T-Mobile G1 becomes the 1st smartphone with the Android platform ● In Sept. 2009, Android 1.6 is released ● In Oct. 2009, Android 2.0 is
  • 31. Android vs. iPhone ● Operating Systems: Android apps can be developed on Windows, Linux, and Mac OS; iPhone apps only on a Mac ● Programming Languages: Android apps can be developed in Java, C/C++, and increasingly in Python and Perl; Objective C is the only choice for serious iPhone development for now ● Source Code Availability: Android is mostly open source; iPhone is 100%
  • 32. Android vs. iPhone ● Third-party Software Distribution: There is a small entry fee for publishing Android apps on the Android market; there is an Apple-centered certification process to make your apps available in the App Store ● Different Philosophies: Bottom-up openness (Android) vs. Top-down quality control (iPhone)
  • 33. Android Software Stack USER APPLICATIONS UI Widgets Activities Services Multimedia Telephony Resources Java SE Connectivity SQLite DALVIK VM C LIBRARIES
  • 34. Dalvik Virtual Machine ● Dalvik is the name of a town in Iceland ● Dalvik VM is written by Daniel Bornstein ● Dalvik VM takes the generated .class files and combines them into one or more .dex files (Dalvik executables) ● It reuses the information from .class files to reduce the size of the footprint ● Dalvik VM uses the registers as the primary source of data storage instead of the
  • 35. Android Application Components through Proverbial Hello, Android!
  • 36. View ● A View is a UI building block: a text field, a label, a button, etc ● Views are hierarchical objects that know how to draw themselves ● J2EE and Swing use the same term - view ● In MS GUI lingo, views are
  • 37. Activity ● An Activity is a single screen in an application ● An Activity typically contains at least one view ● An application may have several
  • 38. Intent ● A Message object that announces an intention ● An Intent can broadcast a message ● An Intent can start a service ● An Intent can launch an activity ● Intents are initiated by
  • 39. Content Provider ● A Mechanism (essentially, an API) for applications to share data without exposing the underlying storage details ● The underlying data can be stored in a file or a
  • 40. Service ● A Background process that typically runs for a long time ● Example: an email application that polls for new messages ● Local services are services accessible to the hosting application ● Remote services are services that can be used by other applications on the
  • 41. AndroidManifest.xml ● An XML file that defines the contents and behavior of the application ● It contains the list of activities in the application ● It contains intent filters, access permissions, use permissions,
  • 42. XML
  • 43. XML Resources ● W3Schools XML Tutorial – ● IBM Developworks Introduction to XML –
  • 44. XML ● XML is not just for Android ● XML is a critical component of modern software engineering – Mobile – Web – Databases – Data ● Most major languages now have libraries to support
  • 45. What is XML ● XML stands for eXtensible Markup Language ● It is extensible – You can define your own XML-document tags ● It uses markup – Uses tags, e.g. <LinearLayout> ● It is a language – A language for defining new languages, e.g., the UI specification language for
  • 46. Why XML ● XML gives documents a tree structure ● That structure can be exploited depending on how the data are used – Visual display – Information extraction ● HTML looks similar, but it lacks semantic structure ● XML is just text so can be viewed in an text
  • 47. Sample XML <address> <name> <first-name>John</first-name> <last-name>Sorensen</last-name> </name> <street>4205 Old Main Hill</street> <city>Logan</city> <state>UT</state> <postal-code>84322</postal-code> </address>
  • 48. XML Terms ● Tags – Text between < and > – Starting tags – no slash ● <name> – Ending tags start with </ ● </name> ● Elements – Everything between a start and end tag ● The name element contains two elements: first and last
  • 49. Attributes ● Attributes – Name/value pair inside a start tag – Attribute values should be quoted – Original document has no attributes ● See next slide for altered
  • 50. Attributes vs Elements ● Which is correct? – age is an element <person> <name>Cynthia</name> <age>25</age> </person> – age is an attribute <person age=”25”> <name>Cynthia</name> </person>
  • 51. Attribute vs. Elements ● Attributes – Cannot contain multiple values – Cannot contain tree structures – Not easily expandable ● Elements – Can contain multiple values – Can contain tree structures – Easily
  • 52. Writing XML ● Tag names are case sensitive ● Values in attributes must be quoted (single or double) ● Elements must be nested properly – This is OK: <employee><name>Bob</name></employee> – This is not OK: <employee><name>Bob</employee></name>
  • 53. Empty Elements ● Some elements may have no data between the start and end tags. ● If so, can shorten the code by ending tag with /> – Long form (John does not have a pet) <person> <name>John</name> <petName></petName> </person> – Short form <person> <name>John</name> <petName/> </person>
  • 54. XML Comments ● Start with <!-- and end with --> <bin_tree_node> <!-- this is a binary tree node --> <key>123</key> <value>nodes value</value> </bin_tree_node>
  • 55. Entities ● Some special characters are called entities in XML ● Must be written using predefined character entities – &lt; for less than ( < ) – &gt; for greater than ( > ) – &amp; for ampersand ( & ) – &apos; for apostrophe ( ) – &quot; for quotation mark (“)
  • 56. Entity example <test> <x>5</x> <comparison>&lt;</comparison> <y>10</y> <result>true</result> </test>
  • 57. XML Documents ● Each XML document starts with an XML declaration – Example: <?xml version="1.0"?> – Declaration may have additional attributes such as encodings for language <?xml version="1.0" encoding="utf-8" ?> – Each document has one root
  • 58. XML Document <?xml version="1.0" encoding="utf-8" ?> <people> <person> <name>Bill</name> <age>21</age> </person> <person> <name>Sue</name> <age>22</age> </person> </people>
  • 59. XML Namespaces ● Anyone can define XML tags ● You may want to use the tags defined by both you and someone else – Both of you may define a similar tag ● XML namespaces provide a way to for similar tags to refer to different data – A title tag for a book – A title tag for the books
  • 60. Defining an XML Namespace ● You will see an attribute starting with xmlns: – <bookstore xmlns:books="" xmlns:author=""> – The name after the : is the namespace – The value is just a string ● Often a URI since URIs are supposed to be
  • 61. Defining XML Document ● To define the tags, one creates one of these: – Document Type Definition (DTD) which defines ● the elements that can appear, ● the order in which they can appear ● how they can be nested inside each other, ● other basic details . – XML Schema. ● Can define same info as DTD ● Supports data types and more complicated rules ● We will not define any in this
  • 62. Handling XML Documents ● Document Object Model (DOM) Parsers – Read everything into memory – Treat XML like a tree ● Simple API for XML (SAX) Parsers – Treat XML like a stream – Generates events as data in the XML is read ● Android – Supports both types of parsers – Has additional support for handling GUI-related
  • 63. Feedback Bugs, errors to vladimir dot kulyukin at gmail dot