You are on page 1of 27

Android Course Lecture-3 and 4

CSDAN0101
Ramakrishna Reddy K Graduate Student ME Computer Science

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

Think about it !!
Witricity: (Marin Soljacic)

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

Animation
In this section, you'll learn how to write a simple animated game and be introduced 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

Animation
Ball/Image Sprite Events

Animation
Reacting to Touch and the Ball Reaching an Edge

Variables

Animation

Randomness

Conditional blocks
This chapter discusses apps that branch to execute different functions based on some condition.
If and Ifelse Blocks

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

Conditional Blocks
Sample: Mastermind

10

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
Selecting an Item

11

Lists
Text Random Using a List

Using Length of List

12

Lists

Toggling through colors using a list.

13

Lists

14

Lists
Iterating Through a List: For Each

15

Iteration
Computing the Sum of the First Three Numbers

16

Iteration

17

Web Services, APIs and Mashing Data


This chapter introduces web services, APIs, RSS, and mashups, then steps through the development of an Android app that communicates with the Twitter 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-line transactions. Such custom bookstores are possible because Amazon, like many sites, provides two levels of access to information: a human interface and an application programmer interface (API)
18

Web Services, APIs and 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 and create 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

Web Services, APIs and Mashing Data


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

20

Web Services, APIs and 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 XML format. An App Inventor Twitter Client for Android

21

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 retrieve them later. Persistent data is information stored in a database or a file. It is persistent in that even when the user closes the app, the data lives on.

22

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

Persistent Data

24

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 and speech 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 list of math and logic blocks.

25

App Inventor Capabilities and Limitations


Database access, both on the device and on the web. So you can save data persistently, and with a web database share data amongst phones. Access to web information sources (APIs)-- you can bring in data from Facebook, Amazon, etc. See limitations below.

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

26

References

Image courtesy : Google App Inventor web site. http://developer.android.com Wikipedia

27

27

You might also like