0% found this document useful (0 votes)
20 views45 pages

Mad Notes

Uploaded by

alluarjunreddy26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views45 pages

Mad Notes

Uploaded by

alluarjunreddy26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Semester –V

MOBILE APPLICATION DEVELOPMENT

UNIT-1 10 Hrs
Introduction to Android ,open headset alliance, Android Ecosystem, Need of Android ,
Features of Android, Tools and software required for developing an Application, Android
architecture

UNIT-2 12 Hrs
operating system, java JDK, Android SDK, Android development tools, Android virtual
devices, steps to install and configure Android studio and sdk

UNIT-3 14 Hrs
control flow, directory structure, components of a screen, fundamental UI design, linear
layout, absolute layout , table layout, relative layout, text view, edit text, button, image
button, radio button, toggle button, radio group, check box, and progress bar, list view , grid
view, image view , scroll view, time and date picker

UNIT-4 12 Hrs
android platform services, Android system Architecture, Android Security model,
Applications development: creating small application

UNIT-5 12 Hrs
Introduction of MIT App Inventor,Application Coding 5.3Programming Basics & Dialog, More
Programming Basics, Alarm Clock Application, Audio & Video, Drawing Application File
Game, Device Location,Web Browsing

Text Books:

1. Erik Hellman, “Android Programming – Pushing the Limits”, 1st Edition, Wiley India
Pvt Ltd, 2014.
2. App Inventor : create your own Android apps by Wolber, David (David Wayne)
MOBILE APPLICATION DEVELOPMENT

A BRIEF HISTORY OF MOBILE

Mobile phones have changed the way we live our lives providing voice calling, text
messaging and mobile Internet access. The very first mobile phones were two-way
radios that allowed taxi drivers and the emergency services to communicate. Motorola,
on 3 April 1973 was first company to mass produce the first handheld mobile phone.

THE MOBILE ECO-SYSTEM

Mobile Ecosystem is a collection of multiple devices (mobile phones, Tablet, Phablet etc),
software (operating system, development tools, testing tools etc), companies(device
manufacturers, carrier, apps stores, development/testing companies) etc.. and the process
by which data (sms, bank-transactions etc.) is
transferred/ shared by a user from one device to
another device or by the device itself based on some
programs(Birthday, Wedding Messages, Calendar).

Data (Text, Multi-media, and VOICE) sharing can be


done between devices of the same operating system or
different operating systems. Examples – Iphone (IOS)
to Windows Phone, Iphone IOS to Nexus(Android),
Motorola(Android) to Nexus(Android). Data can also be
shared between multiple devices with the same
operating system of the same manufacturer.

Mobile Application Development

• Mobile application development is the process of creating software applications


that run on a mobile device,.
Unit-I

UNIT-1 10 Hrs
Introduction to Android ,open headset alliance, Android Ecosystem, Need of Android ,
Features of Android, Tools and software required for developing an Application, Android
architecture

1. What is Android?

Android is an open source software package that was developed primarily to improve the
mobile user experience and has now become the best-selling operating system for mobile
devices. Android is now a part of Google and the Open Handset Alliance, and the current
version of the Android operating system is Oreo (version 8.0), which was released in August
2017.

 Versions of Android along with their names

 ANDROID1.5 CUPCAKE
 ANDROID1.6 DONUT
 ANDROID2.0-2.1 ÉCLAIR
 ANDROID2.2 FROYO
 ANDROID2.3 GINGERBREAD
 ANDROID3.0 HONEYCOMB
 ANDROID4.0 ICECREAMSANDWICH
 ANDROID4.1-4.3 JELLYBEAN
 ANDROID4.4 KITKAT
 ANDROID5.0 LOLLIPOP
 ANDROID6.0 MARSHMALLOW
 ANDROID7.0 NOUGAT
 ANDROID8.0 OREO
 ANDROID9.0 PIE ANDROID10 Q

2. What is Open Handset Alliance(OHA)

The Open Handset Alliance (OHA) is a business alliance that was created for the purpose of
developing open mobile device standards. The OHA has approximately 80 member
companies, including HTC, Dell, Intel, Motorola, Qualcomm and Google. The OHA's main
product is the Android platform - the world's most popular smartphone platform.

OHA members are primarily mobile operators, handset manufacturers, software


development firms, semiconductor companies and commercialization companies. Members
share a commitment to expanding the commercial viability of open platform development.

OHA member companies back the open platform concept for a number of reasons, as follows:
Lower overall handset costs: Opens up resources, which facilitates the focus on creating
innovative applications, solutions and services.

• Developer-friendly environment: In the open-source community, developers share


notes to expedite application development.
• Post-development: Provides an ideal channel for application marketing and
distribution.

3. Write about Android Ecosystem.


Android ecosystem is nothing but the relationship between Users,
Developers/Programmers, and Hardware equipment makers, the Android ecosystem is
nothing but the mutual dependence between Users, Developers, and equipment makers. they
are independent of each other so one cannot exist without the other.

• Users buy devices and applications


• Equipment makers sell devices, sometimes bundled with applications
• Developers buy devices, then they make and sell applications

4. What is the Need of Android.

Following are the 7 reasons that state why we need an android app development
company:

1. The convenience of your customers

It is good to have a mobile application for your business. People nowadays use smartphones
because smartphones are handy and less time-consuming. Smartphones offer multiple
benefits like users can buy products online, compare various products, find places using
Google Maps, find instant solutions, get knowledge and more.

2. Increase Revenue and Sales

Businesses are taking their business online using an Android or iOS application to make the
shopping experience of their customers very easy. There is a greater chance to increase sales
by offering a smoother shopping experience to their customers.

3. Android app development point of view

a. Android Studio
Android Studio is an excellent IDE for developing Android applications . It is fast and
efficient. Using Android Studio, Android developers can easily set up a new Android project
for different types of Android apps within seconds.

b. Java
This powerful programming language is used on a wide range of devices and operating
systems. To develop an iPhone application, the iPhone developer should know objective C
or Swift programming language that is used for iOS development only.

4. Ease of accessibility

Nowadays, owing to the popularity that the Android operating system has gained, many
manufacturers opt for Android devices. Besides, customers can purchase and download
various Android apps for their Android devices from the Play Store. While it takes a few hours
for an Android app to be available for download, it takes a few weeks for an iOS app to be
available for download in the App Store. An
application can be updated multiple times in
a day on the Google Play Store.

5. Android market prediction

Android is an open-source platform and


provides a growing market, which can lead to
bringing down the price of Android phones
and expanding the market share of Android.

6.Android app submission


Submitting an Android mobile app is cheaper than submitting an iOS app. There is a one-
time investment of $25 for Android app submission, whereas a cost of $99 per year for an
iOS app. You need Apple devices such as Mac, iPhone, iPad to test an iOS app while an
Android app can be tested on Android SDK.

7. Easily port to other operating systems

There are some portability issues with iOS as it is close sourced while Android is fully open
source and can easily port to other operating systems like Ubuntu, Blackberry, Symbian,
and Chrome OS.

Google, LG, Samsung, HTC, Sony, Asus, Motorola, and many other device manufacturing
companies are using Android.

5. Explain Features of Android

1. Most of the users in the world use android smartphones


As discussed before, around 72% of the total users use android. Moreover, this percentage
may even rise in the coming years. Considering this fact, it becomes essential for any
company to develop applications that are supported on android.

2. Interactive User Interface and efficient user experience


Android provides exciting widgets and tools to make your creativity and imagination turn
into reality. Android developers keep on adding exciting features and widgets to make the
user interface quite interactive and smooth. You can use these tools to make your design
and then publish that design.

3. Larger Community Support


Google being the holder of Android, regularly updates forums, provides stable releases and
supports all budding developers. One can use their developer guides, tools, and discussions
to resolve their bugs and developmental issues.

As the community is quite extensive and Android is open source, it is easy to develop such
exciting apps without any difficulty.

4. Easy to share your work and earn money


Google provides flexibility in distributing the apps developed by anyone. After one develops
an app, he or she can quickly go to the Google Play store to publish his/her app and then
earn money. It doesn’t stick to the Google Play store. One can even share his/her app through
other app stores of other manufactures or even directly share through any network.

5. Regular Updates and Security Fixes


Google always tries to give its user the best experience and security. To maintain such
standards, google updates android to its latest stable version with the least to often no bugs
and security issues. Therefore, one can assure safety while working on the stable versions of
android.

6.Explain Android Architecture


Any Operating System has its architecture to carry on various functionalities. Similarly,
android has its architecture. The android architecture gives us an idea about its design and
the build. The android architecture or Android software stack is categorized into five
parts:

1. linux kernel
2. native libraries (middleware),
3. Android Runtime
4. Application
Framework
5. Applications

1) Linux kernel

It is the heart of android


architecture that exists at
the root of android
architecture. Linux
kernel is responsible for
device drivers, power
management, memory
management, device
management and resource access.

Linux Kernel carries all the drivers for the low-level devices like Audio Driver, Wi-Fi Driver,
Flash Memory Driver, Bluetooth driver, Camera Driver, Keypad Driver, etc. It is also the
abstract layer of android.

2) Native Libraries
On the top of linux kernel, their are Native libraries such as WebKit, OpenGL, FreeType,
SQLite, Media, C runtime library (libc) etc.

The WebKit library is responsible for browser support, SQLite is for database, FreeType for
font support, Media for playing and recording audio and video formats.

There are several libraries to provide various functionality for purposes like android
development. These libraries are written in C/C++ and are an essential part of architecture.

3) Android Runtime

In android runtime, there are core libraries and DVM (Dalvik Virtual Machine) which is
responsible to run android application. DVM is like JVM but it is optimized for mobile
devices. It consumes less memory and provides fast performance.

It provides us with an environment for executing and debugging our android applications.

4) Android Framework

On the top of Native libraries and android runtime, there is android framework. Android
framework includes Android API's such as UI (User Interface), telephony, resources,
locations, Content Providers (data) and package managers. It provides a lot of classes and
interfaces for android application development.

5) Applications

On the top of android framework, there are applications. All applications such as home,
contact, settings, games, browsers are using android framework that uses android runtime
and libraries. Android runtime and native libraries are using linux kernal.

7.Explain the various tools and software required to develop android applications.

Here are the top favorite tools currently being used for Android application development.

1. Android Studio
As the official integrated development environment for all Android applications, Android
Studio always seems to top the list of preferred tools for developers.

Google created Android Studio back in 2013. It replaced – or should we say it eclipsed? –
Eclipse Android Development Tools (ADT) as the primary IDE for native Android app
development.

Android Studio provides code editing, debugging, and testing tools all within an easy-to-use
drag-and-drop interface. It is free to download and is supported not only by Google, but also
by a large and actively engaged community of Android developers.

2. ADB (Android Debug Bridge)


Android Studio includes the Android Debug Bridge, which is a command-line tool or “bridge”
of communication between Android devices and other computers that can be used during
development and the overall debugging and QA process.

By connecting an Android device to the development PC and entering a series of terminal


commands, a developer is able to make modifications as needed to both devices.

3. AVD Manager
Another useful feature of Android Studio is the AVD Manager, the short form for Android
Virtual Device. The AVD Manager is an emulator used to run Android apps on a computer.
This allows developers the ability to work with all types of Android devices to test
responsiveness and performance on different versions, screen sizes, and resolutions.

4. Eclipse
As we mentioned above, there was Eclipse before there was Android Studio. For a long time,
Eclipse was the officially preferred IDE for all Android application development.

Even though Google no longer offers support for Eclipse, many developers still use it to create
Android and other cross-platform apps, as it works very well with many different
programming languages.

5. FlowUp
FlowUp allows us to monitor the performance of all our production apps. Handy dashboards
let you keep track of your stats and metrics, including CPU and disk usage, memory usage,
frames per second, bandwidth, and more.
6. GameMaker: Studio
For Android game app developers, one of the most popular development tools is GameMaker:
Studio. GameMaker provides everything you need to create 2D games using very little code.
It is an extremely user-friendly application with a simple drag-and-drop interface.

7. Genymotion
Another Android emulator, Genymotion helps developers test and preview an application on
over 3,000 device scenarios. Genymotion is popular among gaming developers because it
comes with pre-installed standard Android images and graphics that are quite useful in the
testing process. It also provides greater speed than testing an app on an actual Android
device.

8. LeakCanary

LeakCanary is an open-source Java library that makes it easier to detect and correct
memory leaks in your application. Whenever a leak happens, LeakCanary immediately
notifies you. Then you can utilize the built-in stack trace to fix the problem or issues.

9. Unity 3D
Unity 3D is a cross-platform game development environment used for creating complicated,
graphics-intensive mobile games such as those containing virtual or augmented reality.

You can still use Unity 3D to create simpler 2D-based gaming experiences, but it is more
typically used for advanced gaming development.

10. Visual Studio with Xamarin


Visual Studio is Microsoft’s official integrated development environment and is a free tool for
developers to use. It supports several different programming languages and when combined
with Xamarin, it can be utilized to create native Windows, Android, and iOS applications.

Important questions:

1. What is Android

2. Android Ecosystem

3. Features of Android

4. Need of Android.

5. Various tools and software required to develop android applications.

Unit –II
operating system, java JDK, Android SDK, Android development tools, Android virtual
devices, steps to install and configure Android studio and sdk

1. What is an operating system?


An Operating System (OS) is an interface between a computer user and computer hardware.
An operating system is a software which performs all the basic tasks like file management,
memory management, process management, handling input and output, and controlling
peripheral devices such as disk drives and printers.
An operating system is software that enables applications to interact with a computer's
hardware. The software that contains the core components of the operating system is called
the kernel.
The primary purposes of an Operating System are to enable applications (spftwares) to
interact with a computer's hardware and to manage a system's hardware and software
resources.
Some popular Operating Systems include Linux Operating System, Windows Operating
System, VMS, OS/400, AIX, z/OS, etc. Today, Operating systems is found almost in every
device like mobile phones, personal computers, mainframe computers, automobiles, TV,
Toys etc.
Following are some of important functions of an operating System.

• Memory Management
• Processor Management
• Device Management
• File Management
• Network Management
• Security
• Control over system performance
• Job accounting
• Error detecting aids
• Coordination between other software and users

Memory Management
Memory management refers to management of Primary Memory or Main Memory. Main
memory provides a fast storage that can be accessed directly by the CPU. For a program to
be executed, it must in the main memory.

Processor Management
An Operating System does the following activities for processor management −
• Keeps tracks of processor and status of process. The program responsible for this task
is known as traffic controller.
• Allocates the processor (CPU) to a process.
• De-allocates processor when a process is no longer required.

Device Management
An Operating System manages device communication via their respective drivers. It does the
following activities for device management −
• Keeps tracks of all devices. Program responsible for this task is known as the I/O
controller.
• Decides which process gets the device when and for how much time.
• Allocates the device in the efficient way.
• De-allocates devices.

File Management
A file system is normally organized into directories for easy navigation and usage. These
directories may contain files and other directions.
An Operating System does the following activities for file management −
• Keeps track of information, location, uses, status etc. The collective facilities are often
known as file system.
• Decides who gets the resources.
• Allocates the resources.
• De-allocates the resources.

Other Important Activities


Following are some of the important activities that an Operating System performs −
• Security − By means of password and similar other techniques, it prevents
unauthorized access to programs and data.
• Control over system performance − Recording delays between request for a service
and response from the system.
• Job accounting − Keeping track of time and resources used by various jobs and users.
• Error detecting aids − Production of dumps, traces, error messages, and other
debugging and error detecting aids.
• Coordination between other softwares and users − Coordination and assignment of
compilers, interpreters, assemblers and other software to the various users of the
computer systems.

2. Explain about JDK

The Java Development Kit (JDK) is a cross-platformed software development environment


that offers a collection of tools and libraries necessary for developing Java-based software
applications and applets.

It is a core package used in Java, along with the JVM (Java Virtual Machine) and the
JRE (Java Runtime Environment). if you need in running Java programs on your machine
then you can easily do it using Java Runtime Environment.

However, if you would like to develop a Java-based software application then along with
JRE you may need some
additional necessary tools, which is called JDK.
JDK=JRE+Development Tools

Contents of JDK

The JDK has a private Java Virtual Machine (JVM) and a few other resources necessary for
the development of a Java Application.
JDK contains:
• Java Runtime Environment (JRE),
• An interpreter/loader (Java),
• A compiler (javac),
• An archiver (jar) and many more.

Java Runtime Environment


The Java Runtime Environment in JDK is usually called Private Runtime because it is
separated from the regular JRE and has extra content. The Private Runtime in JDK
contains a JVM and all the class libraries present in the production environment, as well
as additional libraries useful to developers, e.g, internationalization libraries and the IDL
libraries.

Compile and Run Java Code using JDK:


You can use the JDK compiler to convert your Java text file into an executable program.
Your Java text segment is converted into bytecode after compilation which carries
the .class extension.
First, create a Java text file and save it using a name. Here we are saving the file as
Hello.java.

• Java

class Hello{

public static void main (String[] args) {

System.out.println("Hello Geek!");

After that just simply use the javac command, which is used for the compilation purpose
in Java.

“C:\Program Files\Java\jdk-11.0.9\bin\javac.exe” Hello.java


Now you can run your code by simply using the java Hello command, which will give you
the desired result according to your code.

C:\Users\Pinaki\Documents>java hello_world
(Output:) Hello Geek!

The Jar component:

JDK contains many useful tools and among them, the most popular after javac is the jar
tool. The jar file is nothing but a full pack of Java classes. After creating the .class files,
you can put them together in a .jar, which compresses and structures them in a predictable
fashion.

Important Components of JDK

Below there is a comprehensive list of mostly used components of Jdk which are very useful
during the development of a java application.
Component Use

Javac Java compiler converts source code into Java bytecode

java The loader of the java apps.

Javap Class file disassembler,

javadoc Documentation generator,

jar Java Archiver helps manage JAR files.

Appletviewer Debugging of Java applets without a web browser,


xjc Accepts an XML schema and generates Java classes,

Apt Annotation-processing tool,

Jdb Debugger,

Jmc Java Mission Control,

JConsole Monitoring and Management Console,

pack200 JAR compression tool,

Extcheck Utility tool to detects JAR file conflicts,

Idlj IDL-to-Java compiler,

Keytool The keystore manipulating tool,

Jstatd jstat daemon (experimental)

Jstat JVM statistics monitoring tool

Jshell jshell introduced in java 9.

Jstack Prints Java stack traces(experimental)

Jrunscript Java command-line script shell.

3. Explain about Android SDK?


Android SDK stands for Android Software Development Kit which is developed by
Google for Android Platform. With the help of Android SDK, we can create android Apps
easily.

Android SDK is a collection of libraries and Software Development tools that are essential
for Developing Android Applications. Whenever Google releases a new version or update of
Android Software, a corresponding SDK also releases with it. In the updated or new version
of SDK, some more features are included which are not present in the previous version.
Android SDK consists of some tools which are very essential for the development of Android
Application. These tools provide a smooth flow of the development process from developing
and debugging. Android SDK is compatible with all operating systems such as Windows,
Linux, macOS, etc.
Components of Android SDK
Android SDK Components play a major role in the Development of Android applications.
Below are the important components:
1. Android SDK Tools
Android SDK tool is an important component of Android SDK. It consists of a complete set
of development and debugging tools. Below are the SDK developer tools:
• Android SDK Build tool.
• Android Emulator.
• Android SDK Platform-tools.
• Android SDK Tools.
These are shown below :
2. Android SDK Build-Tools
Android SDK build tools are used for building actual binaries of Android App. The main
functions of Android SDK Build tools are built, debug, run and test Android applications.
3. Android Emulator
An Android Emulator is a device that simulates an Android device on your system. Suppose
we want to run our android application that we code. One option is using Android
Emulator. In Android Emulator the virtual android device is shown on our system on which
we run the Android application that we code.
In Android Virtual Emulator all functions that are feasible on real Android mobile is works
on virtual Device like:
• phone calls, text messages.
• stimulate different network speeds.
• specify the location of a device
• access on google play store and lot’s more.

4. Android SDK Platform-tools


Android SDK Platform-tools is helpful when we are working on Project and they will show
the error messages at the same time. It is specifically used for testing. It includes:
• Android Debug Bridge (ADB), is a command-line tool that helps to communicate with the
device. It allows us to perform an action such as Installing App and Debugging App etc.
• Fastboot allows you to flash a device with a new system image.
• Systrace tools help to collect and inspect timing information. It is very crucial for App
Debugging.

5. Android SDK Tools


Android SDK tool is a component of SDK tool. It consists of a set of tools which and other
Utilities which are crucial for the development of Android Application. It contains the
complete set of Debugging and Development tools for android.
6. SDK Platforms
For Each Android Software, one SDK platform is available
These are numbered according to the android version. The new version of the SDK platform
has more features and more compatible but the old version is less compatible with fewer
features. Like in Android 11.0(R) have more compatible and have more feature but the
below versions like Android 10.0(Q), Android4.4(KitKat) have less feature and is less
compatible.
7. SDK Update Sites
In SDK Update Sites, some sites are embedded in it which will check for Android SDK
Updates Tools. In this, one must ensure we don’t unclick the button below because these
are checked by default which will check for updates if we will unclick it then it doesn’t
check updates for those.
4. Explain Android Development Tools (ADT)
1. Android Studio

Developed by Google, Android Studio is an all-rounder integrated development environment


that allows the Android developers to get what they desire without an Integrated
Development Environment or IDE.

Android has Gradle-base support that has features like visual layout editor,
intelligent code editor, real-time profilers and APK analyzer. It acts just like any
other Java IDE in terms of error investigating and file hierarchy.
2. Visual Studio – Xamarin
Xamarin was launched in 2011 which is the best free IDE for delivering an
enterprise- quality, cross-platform approach. Xamarin supplies add-ins to
Microsoft Visual Studio that allows developers to build Android, iOS, and
Windows apps within the IDE

3. IntelliJ IDEA

The framework based assistance, productivity boosters, unobtrusive


intelligence, duplicates, and inspections are provided with the IDE. Using this
IDE, you can do in- depth coding, quick navigation, and error analysis. It
supports mobile app development with the help of Java, Scala, Kotlin, Groovy.

4. Eclipse IDE

It is one of the most popular IDES of Android apps. The open-source software
is free to use. Released under the Eclipse Public License, it holds a large
community having plenty of plugins and configurations. Highly customizable
offers full support for Java programming language and XML.

5. Android Virtual Devices (AVDs)


An Android Virtual Device (AVD) is a configuration that defines the
characteristics of an Android phone, tablet, Wear OS, Android TV, or
Automotive OS device that you want to simulate in the Android Emulator. The
AVD Manager is an interface you can launch from Android Studio that helps you
create and manage AVDs.

1. Explain the Steps to install and configure android Studio and SDK

Installation
Follow steps below for complete installation and configuration of Android Studio.

Step 1) Download Android Studio


You can download Android Studio from this link or go to developer.android.com
homepage and search for downloads. Choose appropriate platform either for windows,
mac or linux. Following are the pre requirements for windows operating system.

Pre-requirements
• Microsoft windows 7/8/10 (32 or 64 bits)
• Minimum 3GB RAM (recommended 8GB)
• 2GB disk space
• 1280 x 800 minimum screen resolution size
• Intel processor for accelerated emulator
• Android SDK

Note: If you don’t have Android SDK, you can download with Android studio.
Go to the end of download’s page and find android-studio-bundle-
162.4069837-windows.exe it includes SDK also.
Step 2) Run .exe file
Now the next step is to launch .exe file you just download. Following screen will appear

Step 1: Run .exe file


Click next and select Android SDK checked if you don’t have it already. Better
is to leave the default settings.

Make sure Android virtual device is also checked.


Step 2: Choose components Next step is to accept license and agreement. Click
on I Agree

Step 3: Accept license


Next step is to set location of installation. Please make sure your disk has
minimum required space before clicking on Next. For Android Studio
installation location must have at least 500MB free space. For Android SDK
installation, selected location must have at least 3.25GB free space.
Step 4: Install location
Next step is to choose the start menu folder, where you want to create shortcut.
If you don’t want to create a shortcut just mark Do not create shortcut.

Step 5: Choose start menu folder And hit Install button.


It will start installation. Once it’s done following window will appear.

Step 6: Finish
This informs you installation has completed. Click Finish. Make sure
Start Android Studio is checked. Following splash screen of Android
Studio will appear.

Step 7: Android Studio Splash Screen


Step 3) Configure Android Studio
When you run it for the first time it will ask for Android Studio settings.

Step 8: Import settings


If you don’t have any previous settings click on the second option (I
don’t have a previous version of Studio or I don’t want to import my
settings).

Step 9: Select theme and click next.


At the very first run it needs to download some necessary components,
wait till it completes.
Step 10: Download components

And it’s all done.


Step 11: Done
Click on Finish and start building your Android apps.
Unit –III

1. Write about Android Directory Structure


Android Studio is the official IDE (Integrated Development Environment) developed by
Google for android app development. After completing the setup of Android Architecture we
can create an android application in the studio. We need to create a new project for each
sample application and we should understand the folder structure.
It looks like this:

The android project contains different types of app modules, source code files, and resource
files. We will explore all the folders and files in the android app.
1. Manifests Folder
2. Java Folder
3. res (Resources) Folder
• Drawable Folder
• Layout Folder
• Mipmap Folder
• Values Folder
4. Gradle Scripts

1. Manifests Folder
Manifests folder contains AndroidManifest.xml for creating our android application. This
file contains information about our application such as the Android version, metadata,
states package for Kotlin file, and other application components. It acts as an intermediator
between android OS and our application.
Following is the manifests folder structure in the android application.
AndroidManifest.xml

2. Java folder
The Java folder contains all the java and Kotlin source code (.java) files that we create
during the app development, including other Test files. If we create any new project using
Kotlin, by default the class file MainActivity.kt file will create automatically under the
package name “com.geeksforgeeks.myfirstkotlinapp” as shown below.

MainActivity.kt and MainActivity.java

3. Resource (res) folder


The resource folder is the most important folder because it contains all the non-code
sources like images, XML layouts, and UI strings for our android application.
res/drawable folder
It contains the different types of images used for the development of the application. We
need to add all the images in a drawable folder for the application development.

res/layout folder
The layout folder contains all XML layout files which we used to define the user interface
of our application. It contains the activity_main.xml file.

res/mipmap folder
This folder contains launcher.xml files to define icons that are used to show on the home
screen.

res/values folder
Values folder contains a number of XML files like strings, dimensions, colors, and style
definitions. One of the most important files is the strings.xml file which contains the
resources.

4. Gradle Scripts folder


Gradle means automated build system and it contains a number of files that are used to
define a build configuration that can be applied to all modules in our application. In
build.gradle (Project) there are buildscripts and in build.gradle (Module) plugins and
implementations are used to build configurations that can be applied to all our application
modules.
2. What are the components of android screen?
There are following four main components that can be used within an Android application

1. Activities
An activity represents a single screen with a user interface,in-short Activity performs actions
on the screen.
For example, an email application might have one activity that shows a list of new emails,
another activity to compose an email, and another activity for reading emails. If an
application has more than one activity, then one of them should be marked as the activity
that is presented when the application is launched.
An activity is implemented as a subclass of Activity class as follows −
public class MainActivity extends Activity {
}

2. Services
A service is a component that runs in the background to perform long-running operations.
For example, a service might play music in the background while the user is in a different
application, or it might fetch data over the network without blocking user interaction with
an activity.
A service is implemented as a subclass of Service class as follows −
public class MyService extends Service {
}

3. Broadcast Receivers
Broadcast Receivers simply respond to broadcast messages from other applications or from
the system.
For example, applications can also initiate broadcasts to let other applications know that
some data has been downloaded to the device and is available for them to use, so this is
broadcast receiver who will intercept this communication and will initiate appropriate action.
A broadcast receiver is implemented as a subclass of BroadcastReceiver class and each
message is broadcaster as an Intent object.
public class MyReceiver extends BroadcastReceiver {
public void onReceive(context,intent){}
}

4. Content Providers
A content provider component supplies data from one application to others on request. Such
requests are handled by the methods of the ContentResolver class. The data may be stored
in the file system, the database or somewhere else entirely.
A content provider is implemented as a subclass of ContentProvider class and must
implement a standard set of APIs that enable other applications to perform transactions.
public class MyContentProvider extends ContentProvider {
public void onCreate(){}
}
Additional Components
There are additional components which will be used in the construction of above mentioned
entities, their logic, and wiring between them. These components are −
S.No Components & Description
1
Fragments
Represents a portion of user interface in an Activity.
2
Views
UI elements that are drawn on-screen including buttons, lists forms etc.
3
Layouts
View hierarchies that control screen format and appearance of the views.
4
Intents
Messages wiring components together.
5
Resources
External elements, such as strings, constants and drawable pictures.
6
Manifest
Configuration file for the application.

3. Explain android UI screen components

UI screen components
A typical user interface of an android application consists of action bar and the application
content area.
• Main Action Bar
• View Control
• Content Area
• Split Action Bar

Understanding Screen Components


The basic unit of android application is the activity. A UI is defined in an xml file.
During compilation, each element in the XML is compiled into equivalent Android GUI class
with attributes represented by methods.

View and ViewGroups


An activity is consist of views. A view is just a widget that appears on the screen. It could be
button e.t.c. One or more views can be grouped together into one GroupView. Example of
ViewGroup includes layouts.

Types of layout
There are many types of layout. Some of which are listed below −
• Linear Layout
• Absolute Layout
• Table Layout
• Frame Layout
• Relative Layout
Linear Layout
Linear layout is further divided into horizontal and vertical layout. It means it can arrange
views in a single column or in a single row. Here is the code of linear layout(vertical) that
includes a text view.
<?xml version=”1.0” encoding=”utf-8”?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:orientation=”vertical” >

<TextView
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:text=”@string/hello” />
</LinearLayout>

AbsoluteLayout
The AbsoluteLayout enables you to specify the exact location of its children. It can be
declared like this.
<AbsoluteLayout
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
xmlns:android=”http://schemas.android.com/apk/res/android” >

<Button
android:layout_width=”188dp”
android:layout_height=”wrap_content”
android:text=”Button”
android:layout_x=”126px”
android:layout_y=”361px” />
</AbsoluteLayout>

TableLayout
The TableLayout groups views into rows and columns. It can be declared like this.
<TableLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_height=”fill_parent”
android:layout_width=”fill_parent” >

<TableRow>
<TextView
android:text=”User Name:”
android:width =”120dp”
/>

<EditText
android:id=”@+id/txtUserName”
android:width=”200dp” />
</TableRow>

</TableLayout>

RelativeLayout
The RelativeLayout enables you to specify how child views are positioned relative to each
other.It can be declared like this.
<RelativeLayout
android:id=”@+id/RLayout”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
xmlns:android=”http://schemas.android.com/apk/res/android” >
</RelativeLayout>

FrameLayout
The FrameLayout is a placeholder on screen that you can use to display a single view. It can
be declared like this.
<?xml version=”1.0” encoding=”utf-8”?>
<FrameLayout
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_alignLeft=”@+id/lblComments”
android:layout_below=”@+id/lblComments”
android:layout_centerHorizontal=”true” >

<ImageView
android:src = “@drawable/droid”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content” />
</FrameLayout>

4. Write about Textview Control.


In android, TextView is a user interface control which is used to set and display the text
to the user based on our requirements. The TextView control will act as like label control and
it won’t allow users to edit the text. A good example of TextView control usage would be to
display textual labels for other controls, like "Enter a Date:", "Enter a Name:" or "Enter a
Password:".
In android, we can create a TextView control in two ways either in XML layout file or
create it in Activity file programmatically.
Specific attributes of TextView controls you will want to be aware of:
• Give the TextView control a unique name using the id property.
• Set the text displayed within the TextView control using the text property
• Set the layout height and layout width properties of the control as appropriate.
Example:

<TextView android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".HelloWorldAppActivity"
android:typeface="serif" android:textColor
="#0F0" android:textSize="25dp"
android:textStyle="italic"
android:gravity="center_horizontal" />

This code makes the text of the TextView control appear in serif font, green color, 25dp
size, italic, and at the horizontal center of the container

5. Write about Edit Text control .

EditText is a user interface (UI) used to retrieve and modify text data from a user in an
Android app. EditText is a subclass of TextView that inherit all the property of TextView.
Nowadays, EditText is represented with the PlainText element in UI, which displays an
empty text field while designing the app. EditText (or PlainText) is used in the app whenever
you need input from the user side and proceed with its text (or value) in your app.

EditText (or PlainText) is not only used to get plain text in your application, but even you can
use it to get values such as email, number, password, etc. To get the value of each type in
EditText, you must specify its input type in its inputType attribute. For example, to input
plain text, set the inputType attribute to "text", and to input only numeric values, set
the inputType attribute to "number".

Syntax of EditText
1. <Layout>
2. ...
3. ...
4. <EditText
5. android: someAttribute1 = "value of attribute1"
6. android: someAttribute2 = "value of attribute2"
7. ...
8. ...
9. android: someAttributeN = "value of attributeN"
10. </EditText>
11. ...
12. ...
13. </Layout>

6. Write about Button Control in android.

A Button is a Push-button which can be pressed, or clicked, by the user to perform


an action.
Button Attributes
Following are the important attributes related to Button control. You can check Android
official documentation for complete list of attributes and related methods which you can use
to change these attributes are run time.
Inherited from android.widget.TextView Class −
Sr.No Attribute & Description
1
android:autoText
If set, specifies that this TextView has a textual input method and
automatically corrects some common spelling errors.
2
android:drawableBottom
This is the drawable to be drawn below the text.
3
android:drawableRight
This is the drawable to be drawn to the right of the text.
4
android:editable
If set, specifies that this TextView has an input method.
5
android:text
This is the Text to display.

7. write about Radio button control in android.

Android radio button is a widget that can have more than one option to choose from. The
user can choose only one option at a time. Each option here refers to a radio button and
all the options for the topic are together referred to as Radio Group. Hence, Radio Buttons
are used inside a RadioGroup.
For Example:
This image shows 4 options of the subjects for a question. In this, each mentioned subject
is a Radio Button and all the 4 subjects together are enclosed in a Radio Group.

8. Write about Toggle buttons in Android .

Android Toggle Button can be used to display checked/unchecked (On/Off) state on the
button.

It is beneficial if user have to change the setting between two states. It can be used to On/Off
Sound, Wifi, Bluetooth etc.

Since Android 4.0, there is another type of toggle button called switch that provides slider
control.

Android ToggleButton and Switch both are the subclasses of CompoundButton class.

Android ToggleButton class

ToggleButton class provides the facility of creating the toggle button.

XML Attributes of ToggleButton class

The 3 XML attributes of ToggleButton class.


XML Attribute Description

android:disabledAlpha The alpha to apply to the indicator when disabled.

android:textOff The text for the button when it is not checked.

android:textOn The text for the button when it is checked.

Methods of ToggleButton class

The widely used methods of ToggleButton class are given below.


Method Description

CharSequence getTextOff() Returns the text when button is not in the


checked state.
CharSequence getTextOn() Returns the text for when button is in the checked
state.
void setChecked(boolean Changes the checked state of this button.
checked)

9. Write about CheckBox control in android.

Android CheckBox is a type of two state button either checked or unchecked.

There can be a lot of usage of checkboxes. For example, it can be used to know the hobby of
the user, activate/deactivate the specific action etc.

Android CheckBox class is the subclass of CompoundButton class.

Android CheckBox class

The android.widget.CheckBox class provides the facility of creating the CheckBoxes.

Methods of CheckBox class

There are many inherited methods of View, TextView, and Button classes in the CheckBox
class. Some of them are as follows:
Method Description

public boolean isChecked() Returns true if it is checked otherwise


false.
public void setChecked(boolean Changes the state of the CheckBox
status)

10. Write a short notes on progress bar in android studio.

We can display the android progress bar dialog box to display the status of work being done
e.g. downloading file, analyzing status of work etc.

In this example, we are displaying the progress dialog for dummy file download operation.

Here we are using android.app.ProgressDialog class to show the progress bar. Android
ProgressDialog is the subclass of AlertDialog class.

The ProgressDialog class provides methods to work on progress bar like setProgress(),
setMessage(), setProgressStyle(), setMax(), show() etc. The progress range of Progress Dialog
is 0 to 10000.
11. Write about List view in android studio.

Android ListView is a view which contains the group of items and displays in a scrollable
list. ListView is implemented by importing android.widget.ListView class. ListView is a
default scrollable which does not use other scroll view.

ListView uses Adapter classes which add the content from data source (such as string array,
array, database etc) to ListView. Adapter bridges data between an AdapterViews and other
Views (ListView, ScrollView etc).
12. Write about Grid view in android studio
Android GridView shows items in two-dimensional scrolling grid (rows & columns) and the
grid items are not necessarily predetermined but they automatically inserted to the layout
using a ListAdapter

Grid view
An adapter actually bridges between UI components and the data source that fill data into
UI Component. Adapter can be used to supply the data to like spinner, list view, grid view
etc.
The ListView and GridView are subclasses of AdapterView and they can be populated by
binding them to an Adapter, which retrieves data from an external source and creates a View
that represents each data entry.
13. Write about image view in android.
ImageView class is used to display any kind of image resource in the android application
either it can be android.graphics.Bitmap or android.graphics.drawable.Drawable (it is a
general abstraction for anything that can be drawn in Android). ImageView class
or android.widget.ImageView inherits the android.view.View class which is the subclass
of Kotlin. AnyClass.Application of ImageView is also in applying tints to an image in order
to reuse a drawable resource and create overlays on background images. Moreover,
ImageView is also used to control the size and movement of an image.

14. Write about ScrollView control in android.

The android.widget.ScrollView class provides the functionality of scroll view. ScrollView is


used to scroll the child elements of palette inside ScrollView. Android supports vertical scroll
view as default scroll view. Vertical ScrollView scrolls elements vertically.

Android uses HorizontalScrollView for horizontal ScrollView.

15. Write about Time picker control in android.


Android Time Picker allows you to select the time of day in either 24 hour or AM/PM mode.
The time consists of hours, minutes and clock format. Android provides this functionality
through TimePicker class.
In order to use TimePicker class, you have to first define the TimePicker component in your
activity.xml. It is define as below −
<TimePicker
android:id="@+id/timePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

After that you have to create an object of TimePicker class and get a reference of the above
defined xml component. Its syntax is given below.
import android.widget.TimePicker;
private TimePicker timePicker1;
timePicker1 = (TimePicker) findViewById(R.id.timePicker1);

In order to get the time selected by the user on the screen, you will use getCurrentHour() and
getCurrentMinute() method of the TimePicker Class. Their syntax is given below.
int hour = timePicker1.getCurrentHour();
int min = timePicker1.getCurrentMinute();

16. Write about Date picker in android studio.

Android Date Picker allows you to select the date consisting of day, month and year in your
custom user interface. For this functionality android provides DatePicker and
DatePickerDialog components.
In this tutorial, we are going to demonstrate the use of Date Picker through DatePickerDialog.
DatePickerDialog is a simple dialog containing DatePicker.
In order to show DatePickerDialog , you have to pass the DatePickerDialog id
to showDialog(id_of_dialog) method. Its syntax is given below −
showDialog(999);

On calling this showDialog method, another method called onCreateDialog gets


automatically called. So we have to override that method too. Its syntax is given below −
@Override
protected Dialog onCreateDialog(int id) {
// TODO Auto-generated method stub
if (id == 999) {
return new DatePickerDialog(this, myDateListener, year, month, day);
}
return null;
}

In the last step, you have to register the DatePickerDialog listener and override its onDateSet
method. This onDateSet method contains the updated day, month and year. Its syntax is
given below −
private DatePickerDialog.OnDateSetListener myDateListener = new
DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker arg0, int arg1, int arg2, int arg3) {
// arg1 = year
// arg2 = month
// arg3 = day
}
};

UNIT-4
Android platform services, Android system Architecture, Android Security model,
Applications development: creating small application
1. Explain Android platform service
The Android platform provides and runs predefined system services and every Android
application can use them, given the right permissions. These system services are usually
exposed via a specific Manager class. Access to them can be gained via the
getSystemService() method.

Permission
The purpose of a permission is to protect the privacy of an Android user. Android apps must
request permission to access sensitive user data (such as contacts and SMS), as well as
certain system features (such as camera and internet). Depending on the feature, the
system might grant the permission automatically or might prompt the user to approve the
request.
Add permissions to the manifest
On all versions of Android, to declare that your app needs a permission, put a <uses-
permission> element in your app manifest, as a child of the top-level <manifest> element. For
example, an app that needs to access the internet would have this line in the manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.snazzyapp">

<uses-permission android:name="android.permission.INTERNET"/>

<!-- other permissions go here -->

<application ...>
...
</application>
</manifest>

Life Cycle of Android Service

There can be two forms of a service. The lifecycle of service can follow two different paths:
started or bound.

1. Started
2. Bound

1) Started Service

A service is started when component (like activity) calls startService() method, now it runs
in the background indefinitely. It is stopped by stopService() method. The service can stop
itself by calling the stopSelf() method.

2) Bound Service

A service is bound when another component (e.g. client) calls bindService() method. The
client can unbind the service by calling the unbindService() method.

The service cannot be stopped until all clients unbind the service.
Like any other components service also has callback methods. These will be invoked
while the service is running to inform the application of its state. Implementing these in
your custom service would help you in performing the right operation in the right state.

onCreate()
This is the first callback which will be invoked when any component starts the service. If
the same service is called again while it is still running this method wont be invoked.
Ideally one time setup and intializing should be done in this callback.

onStartCommand()
This callback is invoked when service is started by any component by calling
startService(). It basically indicates that the service has started and can now run
indefinetly.

onBind()
This is invoked when any component starts the service by calling onBind.
onUnbind()
This is invoked when all the clients are disconnected from the service.

onRebind()
This is invoked when new clients are connected to the service. It is called after onUnbind

onDestroy()
This is a final clean up call from the system. This is invoked just before the service is being
destroyed. Could be very useful to cleanup any resources such as threads, registered
listeners, or receivers.

2. Explain Android System Architecture


The android system consists of five layers and each layer consists of some core components.
Figure shows the architecture of android.
From top to down, the core components are: Applications, Application Framework,
Native C libraries, Android Runtime Environment (JVM), HAL (Hardware Abstract Layer),
Linux Kernel.
1. Applications. Application layer consists of many core Java-based applications, such
as calendar, web browser, SMS application, E-mail, etc.
2. Application Framework. Application framework consists of many components and
Java classes to allow android application developers to develop various kinds of
applications. By using Java language, it hides the internal implementation of
system core functions and provides the developers an easy-use API. Basically, it
includes Java core class and some special components of android. Some typical
components are as follows: View (List, Grids), Content Provider, Resource Manager,
Activity Manager.

3. Native C Libraries. In Native C library layer, it consists of many C/C++ libraries. And the
core functions of android are implemented by those libraries. Some typical core libraries
are as follows: Bionic C lib, OpenCore, SQLite, Surface Manager, WebKit, 3D library.
4. Android Runtime Environment. Runtime environment consists of Dalvik Java virtual
machine and some implementations of Java core libraries.
5. HAL. This layer abstracts different kinds of hardwares and provides an unified program
interface to Native C libraries. HAL can make Android port on different platforms more
easily.
6. Linux Kernel. Android’s core system functions (e.g., safety management, RAM
management, process management, network stack) depend on Linux kernels.

3. Explain Android Security Model

The Android security model is primarily based on a sandbox and permission


mechanism. Each application is running in a specific Dalvik virtual machine with a
unique user ID assigned to it, which means the application code runs in isolation from
the code of all others applications. As a consequence, one application has not granted
access to other applications’ files.

Android application has been signed with a certificate with a private key Know the owner
of the application is unique. This allows the author of The application will be identified
if needed. When an application is installed in The phone is assigned a user ID, thus avoiding
it from affecting it Other applications by creating a sandbox for it. This user ID is
permanent on which devices and applications with the same user ID are allowed to run
in a single process. This is a way to ensure that a malicious application has Can not
access / compromise the data of the genuine application.

It is mandatory for an application to list all the resources it will Access during installation.
Terms are required of an application, in The installation process should be user-based
or interactive Check with the signature of the application.
Declaring and Using Permissions
The purpose of a permission is to protect the privacy of an Android user. Android apps
must request permission to access sensitive user data (such as contacts and SMS), as well
as certain system features (such as camera and internet). Depending on the feature,
the system might grant the permission automatically or might prompt the user to approve
the request. (2)

Permissions are divided into several protection levels. The protection level affects
whether runtime permission requests are required. There are three protection levels that
affect third-party apps: normal, signature, and dangerous permissions.

Normal permissions cover areas where your app needs to access data or resources
outside the app’s sandbox, but where there’s very little risk to the user’s privacy or the
operation of other apps. For example, permission to set the time zone is a normal
permission. If an app declares in its manifest that it needs a normal permission, the system
automatically grants the app that permission at install time. The system doesn’t prompt the
user to grant normal permissions, and users cannot revoke these permissions.

Signature permissions: The system grants these app permissions at install time, but only
when the app that attempts to use permission is signed by the same certificate as the app
that defines the permission.

Dangerous permissions

cover areas where the app wants data or resources that involve the user’s private
information, or could potentially affect the user’s stored data or the operation of other apps.
For example, the ability to read the user’s contacts is a dangerous permission. If an app
declares that it needs a dangerous permission, the user has to explicitly grant the permission
to the app. Until the user approves the permission, your app cannot provide functionality
that depends on that permission. To use a dangerous permission, your app must prompt the
user to grant permission at runtime. For more details about how the user is prompted, see
Request prompt for dangerous permission.

Using Custom Permission


Apps can define their own custom permissions and request custom permissions from other
apps by defining <uses-permission> elements. To enforce your own permissions, you must
first declare them in your AndroidManifest.xml using one or more <permission> elements.

4. Explain the steps for Building an Android application

The following ate the steps required for building an adroid application.

Step 1: Create a new project

1. Select File > New Project.


2. Fill out the Create Android Project dialog, and click Next.
The requirements for the new project include:

• Application name
• Company domain (this gets reversed into com.domain) to keep applications
partitioned even if they have the same Application name.
• Project Location – where to store the files
• The Package name is suggested from the Application Name and Company
domain
• By default, Android applications are written in Java. If you want to support
alternate languages, such as C++ (for native code) or Kotlin, select the
appropriate check boxes.
Then, click Next.
On the Add an Activity to Mobile dialog, select the Empty Activity type. Then, click Next.

This will create a default application ready to be built and run directly from Android
Studio.

Step 2: Review the code

The following figure shows the components of our new project:


Resources for the application

Resources in Android are organized into a subdirectory of the project named res, as described
previously. Resources fall into a number of categories. Three of these categories are:

• Drawables - This folder contains graphics files, such as icons and bitmaps
• Layouts - This folder contains XML files that represent the layouts and views of the
application. These will be examined in detail below.
• Values - This folder contains a file named strings.xml. This is the primary means for
string localization for the application. The file colors.xml is useful for defining color
codes used by the application. This file is analogous to a css style sheet for those
familiar with web programming techniques.

Step 3: Run the application

Now that the application has compiled successfully, it's time to run the sample application.

To setup an emulator, or more properly, an Android Virtual Device (AVD), select Tools > AVD
Manager. Or, simply click on the Play (Run) icon.

Finally, click OK to launch the application on the selected deployment target. The AVD or
emulator launches with our sample application running on it.

Step 4: Test the application in the emulator

Now that the application is running on the emulator, let's have a look at what is happening
behind the scenes. Within Android Studio, select View > Tool Windows.
UNIT-5
Introduction of MIT App Inventor,Application Coding 5.3Programming Basics & Dialog, More
Programming Basics, Alarm Clock Application, Audio & Video, Drawing Application File
Game, Device Location,Web Browsing

Introduction of MIT App Inventor


MIT App Inventor is an intuitive, visual programming environment that allows everyone
even children to build fully functional apps for smartphones and tablets. Those new to MIT
App Inventor can have a simple first app up and running in less than 30 minutes. And what's
more, our blocks-based tool facilitates the creation of complex, high-impact apps in
significantly less time than traditional programming environments. The MIT App Inventor
project seeks to democratize software development by empowering all people, especially
young people, to move from technology consumption to technology creation.

App Inventor is a free, cloud-based service that allows you to make your own mobile apps
using a blocks-based programming language. You access App Inventor using a web browser
(Chrome, Firefox, Safari).

What is MIT App Inventor?


MIT App Inventor(opens in new tab) is a programming learning tool that is aimed at total
beginners but also novices wishing to advance further. It came about as a collaboration
between Google and MIT. It uses coding to create real-world usable apps for Android and iOS
devices, which students can play.

MIT App Inventor uses drag-and-drop style code building blocks, similar to those used by
the Scratch coding language. This makes it easy to pick up from a young age and also helps
take the otherwise potentially overwhelming complexity out of getting started.

The use of bright colors, clear buttons, and plenty of tutorial guidance all add up to a tool
that helps get even the more tech-troubled learners get up and running. That includes
students being guided by a teacher in class as well as those wishing to get started, alone,
from home.

MIT App Inventor is a web application integrated development environment originally


provided by Google, and now maintained by the Massachusetts Institute of Technology (MIT).
It allows newcomers to computer programming to create application software (apps) for two
operating systems (OS): Android and iOS, which, as of 20 January 2023, is in final beta
testing. It is free and open-source software released under dual licensing: a Creative
Commons Attribution ShareAlike 3.0 Unported license and an Apache License 2.0 for
the source code.
It uses a graphical user interface (GUI) very similar to the programming
languages Scratch (programming language) and StarLogo, which allows users to drag and
drop visual objects to create an application that can be tested on Android and iOS devices
and built to run as an Android app. It uses a companion mobile app that allows for instant
live testing and debugging. In creating App Inventor, Google drew upon significant prior
research in educational computing, and work done within Google on online development
environments.[1]
App Inventor and the other projects are based on and informed by constructionist
learning theories, which emphasize that programming can be a vehicle for engaging powerful
ideas through active learning. As such, it is part of an ongoing movement in computers and
education that began with the work of Seymour Papert and the MIT Logo Group in the 1960s,
and has also manifested itself with Mitchel Resnick's work on Lego
Mindstorms and StarLogo.[1][2]
App Inventor also supports the use of cloud data via its CloudDB component.[3]

,Application Coding 5.3Programming Basics & Dialog, More Programming Basics, Alarm
Clock Application, Audio & Video, Drawing Application File Game, Device Location,Web
Browsing

Build a balloon pop game!

When you are done you and your friends will be able to use this app to play a fun game of
pop the balloon!

• We will use Image Sprite components—programmable moving images—to create balloons


that drop from the sky

• The player will have to “pop”—that is, click on—the balloons before they reach the bottom
of the screen

Step1: Click “Start a new project” give it a name and click “Ok” to get started!

Step2 : Add components! To build this app you will need five components—a canvas, three
image sprites, and a clock. Find these components in the Palette and drag and drop them
onto the Viewer

Step 3: Upload media files, To complete this app you will need to download a picture of a
balloon, Then you will need to upload it to the App Inventor server by clicking the upload file
buBon under “Media”

Step 4: Step 6: Set properties

1. Click on Canvas1 and set both the Height and Width to “Fill parent…”
2. 2. Click on Clock1 and set TimerInterval to 500
3. Now lets set the properites of our Image Sprites, Set the X value of ImageSprite1 to 10;
the X value of ImageSprite2 to 100; and the X value of ImageSprite3 to 190
Set Heading to 270
• Set Height to 80 pixels
• Set Width to 80 pixels
• Set Picture to Balloon.png
• Set Speed to 25
• Uncheck the boxes for Enabled, Rotates, and Visible

Step5: Switch to the blocks window to write code

Every half a second (or 500 milliseconds), Clock1’s timer will go off—that’s because we set
the TimerInterval property to 500! When this happens, we would like one of our three Image
Sprites to appear and begin falling to the bottom of the screen. To do this, we have to choose
a Sprite, and we would like that choice to be random. App Inventor lets us do this!

1. First, click on Variables in the Blocks menu and drag out a block

2. Change “name” to “randomNumber”


3. Click on Math in the blocks menu and drag out a block

4. Change “0” to “1” and then click it onto the “initialize global name” block

5. Next, click on Clock1 and drag out a block

6. Click on Variables again and drag out

7. Choose “global randomNumber” from the drop-down list

8. Click on Math again and drag out, Change “100” to “3” and lock the block into place with
the “set global randomNumber”

9. Snap these two into place inside the “when Clock1.Timer” block

Step 6 : We would like the app to do different things depending on which number was chosen
by App Inventor —because we asked it for a random number between one and three, it could
have given us a 1,2, or 3.

1. Click on Control and drag out if then block


2. Click on the “if, then” block’s setting button—the square blue one in the corner
3. Drag out an “else if” and an “else” block from the left and lock them into place in the “if”
block on the right.

Now we need to fill in our “if, then” block. If App Inventor has given us the number 1, we
want to make ImageSprite1 appear; if it has given us the number 2, we want to make
ImageSprite2 appear; otherwise, it must have given us the number 3, and so we want to
make ImageSprite3 appear

1. Click on Logic and drag out a block

2. Click on Variables and drag out a first block

3. Choose “global randomNumber” from the dropdown list and then click this block into
place in the Logic block’s first space.

4. Click on Math and choose a block

5. Change “0” to “1” and click it into place in the Logic block’s second space

You have written code that checks if the randomNumber variable is equal to 1. With just a
small tweak it will be able to check if randomNumber is equal to 2.

1. Copy and paste the block of code you just created. To do so, right click on it and choose
“Duplicate from the drop-down list”
2. On the duplicate block, change the “1” to a “2”

Now, click the two blocks you’ve just made into place in the “if, then” block,

Now we will tell the app what to do, depending on the random number that is selected.

1. Click on ImageSprite1 and drag set block

2. Click on Logic and drag out a True block. Click it into place with the “set
ImageSprite1.Enabled”

3. Duplicate the block as you did before, by right clicking. For the duplicated block, replace
“Enabled” with “Visible” by clicking on the second dropdown list.
4. Lock the two blocks together.

5.Take the group of two blocks and duplicate it twice (so that you get three copies).

6. Keep the original as it was, but change “ImageSprite1” to “ImageSprite2” in one of the
copies, and to “ImageSprite3” in the other

Step 7 : Okay, great, we have balloons that appear randomly and fall to the bottom of the
phone, but we would like for something to happen when we touch them.

1. Click on ImageSprite1 and drag out a block

2. Also under ImageSprite1, click on a block

3. Duplicate it twice to get three copies, and click them together to form a stack:

When each balloon is touched, we want to return it to its original state. This means resetting
its Y, Visible, and Enabled properties.

1. Grab the stack of blocks you made in the last slide. Change the Y of one block to Visible
using the dropdown menu, and the other Y to Enabled.

2. Set ImageSprite1.Y to 10, and ImageSprite1.Visible and ImageSprite1.Enabled to False.

3. Click this stack into the “when ImageSprite1.Touched” block

The app should do the same thing when ImageSprite2 or ImageSprite3 are touched. That
means we can reuse the same stack of blocks and just change the sprite name.

1. Duplicate the when ImageSprite1.Touched group of blocks twice (to get three copies)

2. For one of the group of blocks, change all mention of “ImageSprite1” to “ImageSprite2”

3. For the other, change all mention of “ImageSprite1” to “ImageSprite3

Step 8. Testing and Debugging.

In order to test your app, you will need an Android phone with the MIT AI2 Companion app
installed. To download the Companion from the app store, scan the QR code below or search
directly for “MIT AI2 Companion” on the Google Play Store.

Open the AI2 Companion app. You can then either input the 6-letter code or scan the QR
code to connect.

This example will show you how to add a media file (a sound in this case) to your Screen and
play it by clicking a button.

DESIGNER SECTION

1. Start a new project and name it “PlaySound”


2. Add an HorizontalArrangement. Click on it in the Components section and change
its width and height to “Fill parent”. Then, change the alignHorizontal and alignVertical
to “center”
3. Add a Button and change its text to “Play”
4. Click on Media in Palette and add a Sound. As you can see, media components do not
appear on Screen1. To be sure you have added your media, you just need to check if it’s
included as a non-visible component on the bottom and it has appeared on the
Components section, on the right.
5. Now you need to upload a file for your sound. Click on “sound” in the Components
section and then upload the file by clicking on “Source”.

BLOCKS SECTION

We have created the visual part of our app, now let’s include the blocks of code to play the
sound when the button is clicked. Click on Button on the right side of the screen and drag
the following block:

when Button1.Click
do

Then, click on Sound and drag the code:

call Sound1.Play

Now, run the app with Emulator and listen to your song.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy