Android Beginner Lecture 3-4

download Android Beginner Lecture 3-4

of 27

Transcript of Android Beginner Lecture 3-4

  • 7/29/2019 Android Beginner Lecture 3-4

    1/27

    Android Course Lecture-3 and 4

    CSDAN0101

    1

    Ramakrishna Reddy KGraduate Student

    ME Computer Science

  • 7/29/2019 Android Beginner Lecture 3-4

    2/27

    Agenda App Inventor Tool

    Animation Conditional Blocks

    Lists Iteration Web services , APIs and Mashing Data Persistent Data

    App Inventor Capabilities and Limitations Applications Demo

    2

  • 7/29/2019 Android Beginner Lecture 3-4

    3/27

    Think about it !!

    Witricity: (Marin Soljacic)

    Wireless electricity

    Source: http://www.witricity.com/

    3

    http://www.witricity.com/http://www.witricity.com/http://www.witricity.com/http://www.witricity.com/http://www.witricity.com/http://www.witricity.com/http://www.witricity.com/http://www.witricity.com/
  • 7/29/2019 Android Beginner Lecture 3-4

    4/27

    Animation

    In this section, you'll learn how to write a simple animated game and beintroduced to timer events, randomness, and global variables.

    Animated Objects App Inventor has two types of animated objects: a Ball and an

    ImageSprite .Timer Events To add a timer event, you first add a Clock component to the application in

    the Component Designer .Moving an Object Periodically

    4

  • 7/29/2019 Android Beginner Lecture 3-4

    5/27

    Animation

    Ball/Image Sprite Events

    5

  • 7/29/2019 Android Beginner Lecture 3-4

    6/27

    Animation

    Reacting to Touch and the Ball Reaching an Edge

    6

    Variables

  • 7/29/2019 Android Beginner Lecture 3-4

    7/27

    Animation

    7

    Randomness

  • 7/29/2019 Android Beginner Lecture 3-4

    8/27

    Conditional blocks

    This chapter discusses apps that branch to execute different functionsbased on some condition.

    8

    If and Ifelse Blocks

  • 7/29/2019 Android Beginner Lecture 3-4

    9/27

    Conditional blocks

    Sample: Calling a random friend from a set of friends.

    9

  • 7/29/2019 Android Beginner Lecture 3-4

    10/27

    Conditional Blocks

    Sample: Mastermind

    10

  • 7/29/2019 Android Beginner Lecture 3-4

    11/27

    Lists This chapter describes how to work with lists of data in an App Inventor

    application. A list is a variable, but instead of representing a single memory cell, it

    represents an array of cells: E.g. : PhoneNumberList

    |3219872 |4153297878 |4592371|

    Making a List

    11

    Selecting an Item

  • 7/29/2019 Android Beginner Lecture 3-4

    12/27

    Lists

    Text Random Using a List

    12

    Using Length of List

  • 7/29/2019 Android Beginner Lecture 3-4

    13/27

    Lists

    13

    Toggling through colors using a list.

  • 7/29/2019 Android Beginner Lecture 3-4

    14/27

    Lists

    14

  • 7/29/2019 Android Beginner Lecture 3-4

    15/27

    Lists

    Iterating Through a List: For Each

    15

  • 7/29/2019 Android Beginner Lecture 3-4

    16/27

    Iteration

    16

    Computing the Sum of the First Three Numbers

  • 7/29/2019 Android Beginner Lecture 3-4

    17/27

    Iteration

    17

  • 7/29/2019 Android Beginner Lecture 3-4

    18/27

    Web Services, APIsand Mashing Data

    This chapter introduces web services, APIs, RSS, and mashups, then stepsthrough the development of an Android app that communicates with theTwitter API.

    Web Service: To computer users, the web is a bunch of sites that can be visited with a

    browser. Programmers see things differently-- to them the web is also a huge

    database of information which can be collected and processed (mashed)to create new and interesting apps.

    Consider, for instance, the custom bookstore sites that sell books using

    Amazon's database of information along with their facilities for on-linetransactions. Such custom bookstores are possible because Amazon, like many sites,

    provides two levels of access to information: a human interface and anapplication programmer interface (API)

    18

  • 7/29/2019 Android Beginner Lecture 3-4

    19/27

    Web Services, APIsand Mashing Data

    Mashups: The term mashup perhaps originated in the music field, with Eminem's

    album The Slim Shady LP combining samples from various other songs and artists.

    Today, numerous sites like ccmixter help artists mashup samples andcreate new art. Just as music can be remixed, so can web programs and information. To a programmer, a mashup is a program that takes data from multiple

    sources (APIs) and combines it in interesting ways.

    19

  • 7/29/2019 Android Beginner Lecture 3-4

    20/27

    Web Services, APIsand Mashing Data

    most popular example, and one of the first, is housingmaps.com whichcombines data from craigslist.com and Google's maps API.

    20

  • 7/29/2019 Android Beginner Lecture 3-4

    21/27

    Web Services, APIsand Mashing Data

    RSS(Really Simple Syndication) RSS is a specific XML language that is used by most blogs and in general

    any service that just needs to send out a simple list of items in an XMLformat.

    An App Inventor Twitter Client for Android

    21

  • 7/29/2019 Android Beginner Lecture 3-4

    22/27

    Persistent Data

    Most interesting apps keep track of data over time, usually in some type of database. App Inventor provides two components, TinyDB and TinyWebDB , which allow your app to put things in a database and retrievethem later.

    Persistent data is information stored in a database or a file. It is persistentin that even when the user closes the app, the data lives on.

    22

  • 7/29/2019 Android Beginner Lecture 3-4

    23/27

    Persistent Data

    TinyWebDB: App Inventor provides a component, tinywebdb, which allows for apps to

    store and retrieve data from a database. The component can store data on any web service that follows a particular

    protocol.

    23

  • 7/29/2019 Android Beginner Lecture 3-4

    24/27

    Persistent Data

    24

  • 7/29/2019 Android Beginner Lecture 3-4

    25/27

    App Inventor Capabilities and Limitations

    You can build many apps with App Inventor, but there are limitations. Most of the limitations are due to the immaturity of the tool-- the App

    Inventor team hasn't yet implemented the functionality, but will.

    Capabilities

    Access to most of the phone's functionality: phone calls, SMS texting,sensors for location, orientation, and acceleration, text-to-speech andspeech recognition, sound, video.

    The ability to invoke other apps, with the ActivityStarter component Programming control just as with a textual language. There are blocks for

    conditionals (if, ifelse), foreach, and while, and a fairly comprehensive listof math and logic blocks.

    25

  • 7/29/2019 Android Beginner Lecture 3-4

    26/27

    App Inventor Capabilities and Limitations

    Database access, both on the device and on the web. So you can save datapersistently, and with a web database share data amongst phones.

    Access to web information sources (APIs)-- you can bring in data fromFacebook, Amazon, etc. See limitations below.

    Limitations: Limited UIs. Limited Access to the device Limited Access to Web Limited access to the Android Market

    26

  • 7/29/2019 Android Beginner Lecture 3-4

    27/27

    2727

    References

    Image courtesy : Google App Inventor web site.

    http://developer.android.com

    Wikipedia

    http://developer.android.com/http://developer.android.com/